Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

1 Answer 1

up vote 3 down vote accepted

I guess you could do something with http://www.geonames.org 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

Your Answer

 
discard

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.