0

I am trying to figure out an easy/free way to reverse geocode from city name to zipcode using the google maps v3 api.

Example using Seattle

http://maps.googleapis.com/maps/api/geocode/json?address=seattle&sensor=false

It doesn't return the zipcode (I am aware there can be more than one per city but I would be happy with just the default or whatever I can get)

How can I take this data and then get a zipcode?

Thanks for helping!

1

1 Answer 1

0

Since in big cities there is more than one zip code, you must specify an valid address to get it. For example for http://maps.googleapis.com/maps/api/geocode/json?address=Green+Wood+9206+1st+Ave+NW+Seattle&sensor=false

in the results JSON you get this pair:

        {
           "long_name" : "98117",
           "short_name" : "98117",
           "types" : [ "postal_code" ]
        }

which I suppose is what you are looking for.

5
  • Thanks for helping!... However... I only have the City... Hence the reason I confused :-/ Jun 4, 2013 at 0:42
  • if you only have the city usually you can do this: maps.googleapis.com/maps/api/geocode/… but of course this could change, it's better if you specify the address as mush as you can, adding the state, country etc, otherwise GoogleMaps will give you a "list of the possibilities".
    – Mimo
    Jun 4, 2013 at 1:07
  • hmmm... I tried this and it does work for some cities but not others: Ex. santa barbara doesn't work Jun 4, 2013 at 1:58
  • As I said you need more informations to get the correct ZIP code. Some cities are split up in a number of zip codes, so you need to provide a more accurate location.
    – Mimo
    Jun 4, 2013 at 2:36
  • There must be a reliable way... :-/ Jun 5, 2013 at 2:42

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