Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the Latitude and Longitude for areas outside the U.S

Can the API for Google Maps be used to retrieve the latitude and longitude for a given Postal Code or City+Region combination for foreign countries such as The United Kingdon, France, Italy, Japan, Australia etc. ?

I am working on a project that requires local search results. For domestic users I retrieve their lat/lon via a U.S Zip Codes Table in our database. It does not involve showing any maps, just results of other users who are in their area via a radius formula based on lat/lon values. For foreign users' local search results: I am just showing results based on matching City Name.

At the moment non-U.S users lat/lon is being retrieved via PHP GeoIP data. I'd like to be able to retrieve more accurate values depending on the city+region or postal code the user provides.

I am considering getting postal code tables (which have lat/lon fields) for other countries. Or is the Google Map API idea a better solution?

like image 460
Seth Avatar asked Jul 14 '09 03:07

Seth


2 Answers

I have found the results from the Google Maps Geocoder to be pretty good.

To test out your foreign postcodes or addresses (without writing any code), just attach the country name to the string and try it out in the google maps search box.

Or, you can implement the lookup pretty quickly in Javascript:

geo = new GClientGeocoder ();
geo.getLatLng("2337, Australia", function (point) {
        GLog.write(point.lat() + "," point.lng());
    });
like image 77
RedBlueThing Avatar answered Oct 03 '22 07:10

RedBlueThing


I've previously used Google Maps for its geocoding, works well and can work for anywhere in the world.

Use the GClientGeocoder from google and use the 'setBaseCountryCode(countryCode:String)' method to set it to the countries top-level domain (http://en.wikipedia.org/wiki/CcTLD)

like image 20
RodH257 Avatar answered Oct 03 '22 07:10

RodH257