Search code examples
phpgoogle-mapsgoogle-maps-api-3google-geocoder

Getting wrong latitude longitude returned by geocode api for address


While searching for a particular address on google Maps i get the multiple results but the location is correct .However when i try to get the lat/long of the address via geocoding API it returns wrong location lat/long.

This address "19 West 34 Street PH New York 10001 NY" is located in zip code: 10001, and when searched on google it returns multiple address but the location is correct.

But when searched through google with the geocoding API via the URL https://maps.googleapis.com/maps/api/geocode/json?address=19%20West%2034%20Street%20PH+New%20York+NY+10001 it returns wrong results.

Does anybody have any idea regarding the issue?


Solution

  • "19 West 34 Street PH New York 10001 NY" is not a valid postal address, the "PH" is confusing the geocoder. If I remove that from the submitted address, I get a single result in the 10001 zipcode:

    "19 W 34th St, New York, NY 10001, USA"

    Another option would be do use the Places API, that seems to return the correct result with the original string.