Search code examples
google-mapsgeolocation

Latitude and longitude can find zip code?


I am using Google geocoder for lat and lon and my question is, is there a way you can find out zipcode with latitude and longitude?


Solution

  • I think what you are looking for is the address_components[] in the results array. Maybe something like this would work, just typing the below so it might have errors in it but I think you will get the idea.

    http://code.google.com/apis/maps/documentation/geocoding/#Results

    function (request, response) {
      geocoder.geocode({ 'address': request.term, 'latLng': centLatLng, 'region': 'US' }, function (results, status) {
        response($.map(results, function (item) {
          return {
           item.address_components.postal_code;//This is what you want to look at
          }
    }