1
votes

I am surprised whether i am doing any wrong or not. When i am finding the distance between two locations on google maps say maps.google.co.uk and when i query their API i get different result. Am i missing somethng?

Origin:Hyde Park Corner Station, Knightsbridge, London, United Kingdom Destination:The Ritz London, United Kingdom Result: 1.2 miles

And when i am using api:

http://maps.googleapis.com/maps/api/directions/json?origin=Hyde%20Park%20Corner%20Station,%20Knightsbridge,%20London,%20United%20Kingdom&destination=The%20Ritz%20London,%20United%20Kingdom&region=gb&sensor=false&alternatives=true&units=imperial

Result:4.3 miles or 5.0 miles etc.

Why is there so much of difference . Am i missing something.

1
Your first query (on maps.google.co.uk) doesn't return any route for me.geocodezip
And there is always the Google Maps Javascript API FAQgeocodezip

1 Answers

3
votes

There are significant differences between Google Maps and a service like directions(or geocoding)

Google Maps at first is an implementation of Google Places, and that's the issue here. The directions-service uses geocoding to resolve the addresses, while Google Maps uses the PlacesService.

When you draw the route using the directionsRenderer, you will see that there are different start-and end-locations.

But when you first request the PlacesService to get the coordinates of the places, and use these coordinates to request the directionsService, you will get a result near by the result of Google Maps(the duration may differ, because the directionsService by default will not return results depending on the current traffic)