Lokesh Paunikar
Lokesh Paunikar

Reputation: 1709

Get latitude/longitude from zip code

Is there any way (any API or any URL) to find the lat, long by passing the area code (zip code) only?

Upvotes: 2

Views: 8134

Answers (3)

Bryan Weaver
Bryan Weaver

Reputation: 4473

The Google Maps Geocoder will search on just zipcode.

Here is an example: (and a fiddle to see it working)

var geocoder;    
function initialize() {
    geocoder = new google.maps.Geocoder();
}

function codeAddress() {
    var address = document.getElementById("address").value;
    geocoder.geocode({
        'address': address
    }, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            $('#coord').val(results[0].geometry.location);
        } else {
            alert("Geocode was not successful for the following reason: "
                  + status);
        }
    });
}

Google's free version of the API is restrictive when it comes to batch geocoding. If you need to geocode lots of data you may want to look into a geocoding service like: USC's geocoding service.

Upvotes: 3

Jilles van Gurp
Jilles van Gurp

Reputation: 8284

You could try using the yahoo geoplanet dataset. It includes geocoded zipcodes worldwide and a few other things. The main problem with this dataset is that it is no longer maintained so it may be missing newer postalcodes.

Otherwise, you could use a geocoder indeed. Google, Navteq, and Yahoo have such APIs though I don't know if they can geocode just postcodes.

Upvotes: 1

Ernest Friedman-Hill
Ernest Friedman-Hill

Reputation: 81684

You just need to use a database of this information; here's a free one.

Upvotes: 3

Related Questions