A HTML5 mobile app that I was working needed to get the city and province (ie state for you non-Canadians) that the user was in. Using the HTML5 geolocation method made it easy to get the latitude and longitude. But the missing piece was how to translate that into city, county (if applicable) and province/state.
Google maps is the defacto solution in the geolocation space. But their API include a term that requires you to display their map as one of the conditions of using their API (see terms of service). This works for some apps but not always (and not in my case).
SimpleGeo is another popular option. What it has going for it is that there are very few restrictions and the API is very easy to implement. I was able to have code working in less than 30 minutes. The problem is that the data is really only good for locations in the US. If that works for your app, definitely take a look at this. When I tried it with some Canadian locations, there were gaps in the results and some were just wrong. Now to be fair, SimpleGeo is still in beta and maybe somewhere down the line, they will have better support for data outside the USA. Note, when using simplegeo, remember to allow either ‘*’ or localhost in the admin panel if you will be testing from your own machine or a mobile phone. The default is just ‘simplegeo.com’ which will cause your API calls to be rejected.
The only other reasonable option left was Yahoo’s Placefinder API. Now, at first I didn’t expect Yahoo to have something that would be of use. They has been getting getting a trashing over the last year in the press. But as I started to look at the API, I realized that’s actually pretty powerful. And it seems to have good support for outside the United States. Definitely the data that I’ve tried for Canada has been very good. One thing to note is that Yahoo only allows 10K requests per day per app. If you need more than this, you need to contact them and work out an agreement.
The API is pretty straightforward to implement as its a simple HTTP GET. You can give it a latitude and longitude that you got from the HTML5 geolocation method and Yahoo will return all sorts of useful data about the location.
If you want to give the API a quick try, take a look at GeoPlanet Explorer web interface created by one of their ex-Developer Evangelists. In the ‘drilldown’ mode, locations are organized as a tree and the UI lets you see things like a locations parents (ie province & country) and it neighbours.