One of the interesting feature that is currently being tested and incorporated in all major browsers is the Geolocation API. Don’t get scared with the Sci-fi name, the API is nothing but for identifying the user’s location when they access particular website in web. Location identification is not much helpful in the case of desktops, but if the user us using mobile/laptop, then there is a good reason for knowing where the user is.
Sniffing user’s location is not a new thing to web. In fact, most websites does that by means of IP address detection. But, as you must be knowing, detecting user’s location based on IP address is not that much effective. Take my case, even though I’m in Trivandrum Kerala, I often see the messages saying “Welcome, Maharasthra User” in many of the websites.
So, there should be some other way to identify user’s location as correct as possible.
Geolocation API specification:
To enable websites for getting the geolocation information from browsers, W3C has come up with the Geolocation API specification. The whole idea is to get the location information from the devices such as Wifi towers or GPS. Most of the modern phones are now equipped with GPS functionality and so the laptops with Wifi. So, it’s not difficult to get the location information from these devices. But to make use of this, the location information should be made accessible to the websites via the browser.
To enable this, W3C’s Geolocation specification defines an API for scripted access to location information associated with the hosting device, such as mobile or laptop. Geolocation API provides the Geolocation interface with a function getCurrentPosition() which will return the langitude and lattitude information to the function caller (the website). The function signature is:
void getCurrentPosition(in PositionCallback successCallback);
When this function is invoked, the location information will be retrieved from the location provider and then it will be passed on to the call back function, which the website can make use of.
Geolocation API – Supported browsers
As of now, the following browsers support the Geolocation API (some of them are in beta).
| Web Browser | Geolocation API support |
|---|---|
| Mozilla Firefox | supported in Firefox 3.5 and later versions. |
| Chrome | Supports thru Google Gears Geolocation API |
| Opera | Supported in nightly builds – download from this page |
| Safari | Support is coming soon in the IPhone’s Safari browser. |
| Internet Explorer | An experimental support available from IE8. |
What could be the possible uses for the Geolocation API?
After the Web 2.0 ere, now its time for the mobile web. Most of the big companies are already started targeting mobile consumers. In such cases, knowing from where the user is accessing a particular site and customizing the site content depends on the location will have a big impact on the user’s behavior.
Consider this scenario: A customer is going to a mall for buying some electronic gadgets and he/she searches the web for some reviews on the product that he/she is planning to buy. Now, if the review site/search engine could get the user’s location info and do a little processing in the background (with some communication between the mall’s retail database) to find out what are all the items that are closely stored to the user’s location and showing advertisements related to that products, will definitely induce the customer to click on those advertisements and to buy those products.
What I said above is one simple scenario. Similar to this, Geolocation API could be useful in much more places. And, no wonder, it is one of the much expected feature in HTML5 (apart from Video, Canvas and others).
{ 4 trackbacks }
{ 5 comments }
Hi,
your blog is nice and informative..keep it up..
btw, i stumbled upon the Geolocation API of W3C and found this – “User agents must not send location information to Web sites without the express permission of the user. User agents must acquire permission through a user interface”. does that mean getting geolocation is dependent on the user’s approval ? Kindly forgive if I am technically blunt here…
@Space Boy
Yes. you are right. Browsers need to get confirmation from the user before they share the user location with the requesting web sites.
Thanks man, just what I was looking for. Thanks so much…
you are welcome.
We have found an article discussing about this HTML 5 geolocation and IP geolocation.
http://www.ip2location.com/html5geolocationapi….
Comments on this entry are closed.