HTML5 Geolocation

Posted by Paul on December 15, 2011

One of the exciting new features in HTML5 is Geolocation. This allows any website you visit to ask you to share your location, much like an iPhone app.

The business uses are obvious - find a nearby restaurant, hotel, taxi... all these sorts of things should now be possible.

There were a couple of methods for doing this before HTML5, using your IP address. You could either maintain a list of IP address patterns in a database on your website, or you could use a third party service to look up the IP address location of every visitor. Both methods worked to some degree, but often the accuracy was quite low. It would almost always get the correct country, but getting the right city was often a challenge.

Unfortunately it seems that the Geolocation in HTML5 suffers from the same problem. Sharing my location (I'm in Reigate, Surrey) places me in the Bank of England in London!

Try it yourself:
http://html5demos.com/geo