HTML 5 Geo Location API
With recent facebook feature of geo tagging, geo location is becoming a hot field in internet world, considering the future aspects of geo location HTML5 specification has added a new Geolocation API which helps in mapping the exact location of any user to offer personalize location based services.
Lets take a dive into how this geolocation API works and what you can do with this. Geolocation tells you where the user is it is not of much relevance for him knowing his current position. You can track a users current location by embedding just 2 line of javascript
navigator.geolocation.getCurrentPosition(callmeonSuccess, callmeonError, options);
This 2 lines of code will give you the current location, the callmeonSuccess function will be called with position parameter passed which is then used to extract the lat long etc. Here is the code which will give you the lat and long for any user
function callmeonSuccess(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude; }
Yes with this simple line of code you can get the lat and long of any user. There are various other options which you can extract from position. You can play with this API and check with different parameter by going on this link.
You can see the stand alone version of the example application integrated with Google maps on my website.
There are lot of good examples and uses of this geo location feature you can find something similar on html5rocks, I am exploring the possibilities of how to use this feature and in my upcoming posts I will try to put some content related to the same.
You can read the specification of geo location tracking form W3C website. They use a set of GPS, satellite mobile phone tower position IP etc for getting the exact location.
What will you do if you get the location of visitor who is visiting your webpage? post it in your comments.
Thanks
Pranay

