0
votes

I am looking for distance between:
- NE2 4AD
- NE19 1TA


- Via google map I am getting as 34.00 miles


- But via direction API I am getting as 0.54 miles using


https://maps.googleapis.com/maps/api/directions/json?origin=NE24AD+Newcastle Upon Tyne&destination=NE191TA+Newcastle Upon Tyne&units=imperial&key=Your Key

Can anyone help me out...!

Thanks in advance..

1

1 Answers

0
votes

Upon investigation, I can confirm that this behavior is working as intended. In order to get more accurate results, you'll need to supply complete and well-formed origin and destination addresses to the Directions API that follows the addressing conventions or standard format for addresses in your country. This is because the addresses supplied are geocoded in the backend, so incomplete and badly formatted queries are prone to produce zero or inaccurate results.

You can try this request instead with origin "North Terrace, Newcastle upon Tyne NE2 4AD, UK" and destination "Rochester, Newcastle upon Tyne NE19 1TA, UK" which should result to a distance of about 34 mi:

https://maps.googleapis.com/maps/api/directions/json?origin=North+Terrace,+Newcastle+upon+Tyne+NE2+4AD,+UK&destination=Rochester,Newcastle+upon+Tyne+NE19+1TA,+UK&units=imperial&key=YOUR_API_KEY

Please see Geocoding addresses best practices here: https://developers.google.com/maps/documentation/geocoding/best-practices

Hope this helps!