Converting Distance to miles in 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 开发者_StackOverflowat this and appreciate any and all help.
Here is where i am at currently:
http://www.public.asu.edu/~tpeiffer/
It appears that the computeDistanceBetween
function returns distances in meters – to convert to miles, just multiply by the number of miles in a meter:
result *= 0.000621371192;
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!
精彩评论