ZERO_RESULTS from the geocode API for business zip codes

May 12, 2017

We recently ran into a scenario where finding a zip code internationally was not producing any results.

http://maps.googleapis.com/maps/api/geocode/json?components=country:Switzerland|postal_code:4901

{
   "results" : [],
   "status" : "ZERO_RESULTS"
}

We read a little more into the zip code structure in Switzerland and found that it’s a business zip code and didn’t provide lat/lng data like a normal zipcode would (apparently 4901 has a parent zip code of 4900) — that wasn’t helpful news tho.  However, we found a way that hacks the other API structure using the “address” parameter instead of “components”.  You just need to add the word “country” before it – otherwise the results find information to an address in Michigan.

https://maps.googleapis.com/maps/api/geocode/json?address=country Switzerland 4901

The above URL was able to get us the data that we needed for finding locations that were near this zip code.  We haven’t had any rogue results from this method, so hopefully this can help someone else out in the future.

Stay in Touch!

Subscribe to our newsletter.

Solutions Architecture

browse through our blog articles

Blog Archive