How to Google Maps Calculate the Distance From One Place to Another? [Solved]

There could be many ways to calculate distance. You have to first clear if you are using Javascript or Google Maps API V2. So if you are using javascript, then answers from other people are pretty much clear but if you are using API then you simply need to grab data from URL corresponding to Google Directions API. In the data returned from google server will have all information along with distance and time between origin and destination according to mode of transport (like driving, walking etc.). You can even show that data on Google Maps and draw route between them.

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!).
    Haversine formula: 
             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!

  • Comments List

Leave a Comment

  • Related Blogs
Disclaimer:

Number For Help are not associated with any assistance for tarvel, airlines or tech products issues. This is an informatory website for new and existing technology terms, we hereby disclaims any affiliation, sponsorship & endorsement of or by any third party!

Looking for Best and Accurate Solution for your problem ?

Contact us today for more information.

  • www.numberforhelp.com

  • info@numberforhelp.com

  • 454 Stadium Way, Los Angeles, CA, USA 90210