How to Google Maps Calculate the Distance From One Place to Another? [Solved]
Another way to Google Maps calculate the distance from one place to another?
Exact implementation used by google maps isn't publicly available.
One simple implementation to calculate distance between two points(identified by using GPS coordinates) is by using Haversine formula.
‘Haversine’ formula is used to calculate the great-circle distance between two points – that is, the shortest distance over the earth’s surface – giving an ‘as-the-crow-flies’ distance between the points (ignoring any hills they fly over, of course!).
a = sin²(Δφ/2) + cos φ1 ⋅ cos φ2 ⋅ sin²(Δλ/2)
c = 2 ⋅ atan2( √a, √(1−a) )
d = R ⋅ c
where φ is latitude, λ is longitude, R is earth’s radius (mean radius = 6,371km);The angles need to be in radians to pass to trig functions!