1

Is it possible to get the zipcode of a location found using google maps api?

Currently it returns the longitude and latitude, but not the zipcode.

I found this for zipcodes: http://www.census.gov/tiger/tms/gazetteer/zips.txt

I was going to write a script to put it in a DB, but I'm unsure the kind of query you'd write to find the nearest result

azz0r
  • 3,283
  • 7
  • 42
  • 85

2 Answers2

1

One possible solution is to load all of your zipcode data into a table and then, when you need to get the zipcode with the nearest lat/long to the lat/long returned by Google Maps, use the Haversine formula in a query to get the distance between the lat/long from GoogleMaps and the lat/long of the zip codes. You can then select the zip code that is closest to the lat/long returned by Google Maps i.e. the one with the lowest distance from your point of interest.

Luckily there is just such a query in a previous post.

NB This will only give you the nearest zipcode in your list for a location. I do not know whether this means that you will get the correct zipcode for your location (I don't know enough about zipcodes for that!). It should give you something with which to get started though.

Community
  • 1
  • 1
Tom Mac
  • 9,693
  • 3
  • 25
  • 35
0

If you're interested in getting the zip code of a latitude and longitude, you can use ZipLocate, it now supports reverse geocoding.

You could either use the API or use the scripts to query the data locally.

nathancahill
  • 10,452
  • 9
  • 51
  • 91