Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get zip code based on lat & long?

Is there a service or API I can ping, and pass in the lat/long as parameters, where it returns the zip code that lat/long pair is within? This is US-only, so I don't have to worry about international codes, etc.

I feel like Google Maps' reverse-geocoding is too heavy for me. I'd prefer something lighter, if possible. This will be done in javascript.

like image 513
Connor Avatar asked Dec 04 '11 00:12

Connor


2 Answers

It is called Reverse Geocoding (Address Lookup). To get address for lat: 40.714224, lng: -73.961452 query http://maps.googleapis.com/maps/api/geocode/json with parameters latlng=40.714224,-73.961452&sensor=true (example) and it returns JSON object or use http://maps.googleapis.com/maps/api/geocode/xml to return XML response (example). It's from Google and it's free.

like image 98
Michał Powaga Avatar answered Sep 22 '22 19:09

Michał Powaga


For the Google API, you need to use it within a Google map, according to their site:

Note: the Geocoding API may only be used in conjunction with a Google map; geocoding results without displaying them on a map is prohibited.

like image 26
Data Pro Avatar answered Sep 19 '22 19:09

Data Pro