在 Google Maps Javascript API 中将距离转换为英里
我正在谷歌地图中开发一个简单的“直线距离”计算器,并且我一直试图将两点之间返回的距离转换为英里。有一个简单的方法吗?
我对此相当陌生,感谢所有帮助。
这是我目前所在的位置:
Im working on a simple "as the crow flies" distance calculator in Google Maps and im stuck trying to convert the returned distance between two points into miles. Is there an easy way to this?
I am fairly new at this and appreciate any and all help.
Here is where i am at currently:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来computeDistanceBetween函数返回以米为单位的距离——要转换为英里,只需乘以以米为单位的英里数:
It appears that the
computeDistanceBetween
function returns distances in meters – to convert to miles, just multiply by the number of miles in a meter:我猜测距离以米为单位,在这种情况下,您只需将其除以 1609.344 即可。
我的猜测有点雨人...我选择了相距 80 英里车程的两个点,答案约为 90000。因为 90 公里约为 54-55 英里(粗略地在头脑中计算得出的总和),并且它不是直线汽车,这对我来说似乎很合理!
I am going to guess that the distance is given in metres, in which case you simply divide it by 1609.344.
My guess is a bit Rainman... I picked two points which are an 80 mile drive apart and the answer was around 90000. Since 90km is around 54-55 miles (sums done roughly in head) and it's not a straight line in the car, this seems reasonable to me!