I am working on gps tracking in android to track the user location and provide the feature to record the track.I am able to draw path now i want to calculate the track distance and time with that like suppose user start tracking record and move to another location now i want to calculate total distance and time travel for from start to end position (with user location update) in google map. I have function which calculate the distance for 2 position but that not fit for my route, because route are in polyline and it's flexible lat/lng position. is their any api or any function or services provide by google for that. any help or suggestion are appreciate.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
If you do have a set of lat/lon data within a timeline, you can calculate total distance by the sum of the distance between each set in that timeline.
I don’t know which formula you are using to calculate distance, but it is nice to take a look here.
It is a quite sensible topic since you are calculating distance on the surface of something that resemble a.. how can I say that.. a peach.
To illustrate the idea:
Total time: 9hrs
Total distance: (a->b + b->c) = 630km + 342.4km = 972.4km
I would create a class called waypoint
Then create a list of these classes which allows inserting of elements at any position which is helpful if your route changes:
Then convert to array and calculate the totals:
I have implement by my way, I have create inner class which extends the Overlay class to draw the path/route on map
create new object of this class and add into the map overlay like this way
now I have draw the path when the user click on button to record the track and find the total distance and time for that I have create update method which will call from the locationChange() method when gps get new location that location will be pass to the map activity and store into the polyline object of the TrackOverlay class.
ok every time this method was call and update the map with new point and in this I have use the
Geo_Class.distFrom(x1, y1, x2, y2)
my create method which was calculate the distance between two point and when getting new point set to the curr point and curr point will assign to the prev point. same way for time to calculate the total time. and also find the speed for that using this