Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 at this and appreciate any and all help.

Here is where i am at currently:

http://www.public.asu.edu/~tpeiffer/

like image 731
TJP Avatar asked Mar 28 '11 23:03

TJP


People also ask

Is Google Distance Matrix API free?

The Distance Matrix API uses a pay-as-you-go pricing model.


1 Answers

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;
like image 131
Sophie Alpert Avatar answered Oct 21 '22 03:10

Sophie Alpert