Google Maps has a fantastic geolocation API that attempts to translate text representing a location into hard and fast latitude/longitude coordinates. A great service that is in use by many websites, not least Google Maps itself.
For web developers who use the service from their servers, there’s an extra level of complexity to deal with - the geocoding API biases its results towards the country from which the request was made. So “Perth” could be the Scottish town to a user in Britain or the Western Australian capital if the request came from an IP down-under. When your servers are located in one country this can limit their usefulness to an international audience.
The solution is to call the API from an appropriate version of Google Maps, so if your server receives a request from a Japanese IP, call the Google API via maps.google.co.jp. Nice and easy, eh?
No, not quite, because not every country has its own Google Maps address. I searched for a canonical list of them, but could find nothing, so was forced to use a bit of Perl hackery to try every country domain preceded by “http://maps.google.(|co.|com.)”. These are my results:
|Bosnia and Herzegovina||BA||http://maps.google.com.ba|
Hope you find the list useful, I’ll try to keep it up to date as Google rolls out more servers across the world, so don’t forget to bookmark it.
Do you know of a Google Maps domain that I’ve missed? Leave a comment below.
Creative Commons licensed photo by Hive.