如何计算从当前位置到另一个位置位置侦听器的总里程?
您好,有人可以告诉我如何计算从当前位置到另一个位置的总里程吗?例如,我从 A 点开始步行,到达 B 点。我怎样才能找到从 A 点到 B 点的总行程。请帮助我!
Hi Can anybody tell me how can i calculate Total Miles Travel from the Curent location to another location? e.g. like i start walking from point A and reached at point B. how can i find the total distance travel from point A to B. Please help me!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设您有位置
start_location
和finish_location
。所以你可以使用
start_location.distanceTo(finish_location)
请参阅,Android 中的位置
Assume, you have Location
start_location
andfinish_location
.So you can use
start_location.distanceTo(finish_location)
Please See , Location in Android
我已经在我的开源 GPS 跟踪器中解决了这个问题。完整的 Android 项目在这里:
https://github.com/nickfox/GpsTracker /tree/master/phoneClients/android
和执行跟踪的类如下。您想查看名为totalDistanceInMeters 的变量。
I have solved this exact problem in my open source Gps Tracker. The full working android project is here:
https://github.com/nickfox/GpsTracker/tree/master/phoneClients/android
and the class that does the tracking is below. You want to take a look at the variable called totalDistanceInMeters.