Question

What formula is used by Google Maps for calculating the shortest distance between 2 points (having their Lat, Lng coordinates)? AFAIK in API there is a method for this called computeDistanceBetween but how does it work exactly? Is it purely based on Haversine? Or is it something different? Is there a mathematical or code implemenatation reference available somewhere?

UPDATE
It seems Google probably uses the great-circle distance formula assuming on a fragment from their documentation:

The distance between two points is the length of the shortest path between them. This shortest path is called a geodesic. On a sphere all geodesics are segments of a great circle.

Well, that's quite a simplification. It's like saying that every parallel is equal to equator. Or maybe I get it all wrong. In my opinion, this shouldn't work properly when measuring distance between, let's say, from Greenland to Canada, as they are way off the equator. But in Google it gives correct measurements anyway, I don't understand why and how. Are they modifying great-circle formula somehow?

Was it helpful?

Solution

If Google Maps is using the great circle distance then the results are within better than 1% of the geodesic distance for the ellipsoid. If you want to see the true ellipsoidal geodesic path in Google Maps, then visit

http://geographiclib.sourceforge.net/scripts/geod-google.html

This uses Javascript to solve the geodesic problems for an ellipsoid. Wikipedia has a lot of information on ellipsoidal geodesics; see

https://en.wikipedia.org/wiki/Geodesics_on_an_ellipsoid

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top