Search code examples
google-mapsgeocode

Google API for Maps Gecode Function not returning results for a specific zip code


I am posting to the geocode API and for a certain zip code (11707) it returns zero results. I know this is a valid zip. Also with other zips the same post works fine.

The non-working call is:

https://maps.googleapis.com/maps/api/geocode/json?address=11707&key= (i put my key here)

The working call is:

https://maps.googleapis.com/maps/api/geocode/json?address=11950&key= (I put my key here)

Any idea how I can get this resolved?

I was expecting the Geocode API to return the geocoded information for this zip code.


Solution

  • This is an expected behavior for Geocoding when only the postal code is provided as input, as detailed in https://issuetracker.google.com/73030863 and https://issuetracker.google.com/75985322, because a 4-digit or 5-digit number can often represent multiple locations(ambiguous query), even within a single country.

    As a workaround, consider using Component Filtering and/or Region Biasing to narrow down your results.

    This request with component filtering (postal_code & country) returned results: https://maps.googleapis.com/maps/api/geocode/json?components=country:US|postal_code:11707&key=YOUR_API_KEY