Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a situation where user enters a city, state for which we need to find a corresponding zip code. In case there is no corresponding zip code, we are required to find a zip code that close to the city, state.

Can you please throw some ideas as to how to go about doing this using Google maps/geocode API.

EDIT: Is it possible for US that a city entered by user does not have a zip code?

share|improve this question
Is this for a particular country, or worldwide? If the US (or probably other counties), many cities will have multiple zip codes--does that matter to you or is any zip code close to that city OK? – neuhausr Sep 20 '11 at 13:50
@neuhausr If we get multiple zip codes, we will prompt the user to choose one of them. – mohang Sep 21 '11 at 7:44
The Google Maps API geocoding service will only return a zip code if you give it a street address. Giving just the City and State won't return a zip code, most likely because there are usually multiple zipcodes per city (in the US at least). – Casey Sep 21 '11 at 11:54
Every city has at least one ZIP code – Maksim Feb 12 at 14:32
up vote 4 down vote accepted

I guess you could do something with API for getting back zipcodes with cities ands states.

In case it is not found, you could use the geoname parameter postalcode_startsWith and propose results to your user or to you.

But first of all, I would study how the zipcode is built on the country you are working on. Once this done, you could maybe get back more accurate data from geonames API.

share|improve this answer
We got the zip codes from geonames for all the cities of US. This helps to get zip code(s) of any city. Thanks. – mohang Sep 21 '11 at 7:45

I did the simple API to do that using Google Maps Geocoding API.


enter image description here

share|improve this answer

here is a simple API for that: check out

for zip code queries.. http://.../rest/v1/public/boundary?zipcode=20002,20001&format=geojson

returns all geoJson Boundaries,zipcode(s) for a state: http://..../v1/public/boundary?city=Washington&format=geojson

check out the googlemap integration of the above two here:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.