The Geolocation API, as proposed in the W3C draft, is a high-level interface to location information, such as latitude and longitude, associated with the device hosting the implementation. The API itself is agnostic of the underlying location information sources. Common sources of location information include Global Positioning System (GPS) and location inferred from network signals such as IP address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs:

The following code extract illustrates how to obtain basic location information:

The API defined in this specification can be used to retrieve the geographic location of a hosting device. In almost all cases, this information also discloses the location of the user of the device, thereby potentially compromising the user's privacy. A conforming implementation of this specification must provide a mechanism that protects the user's privacy and this mechanism should ensure that no location information is made available without the user's informed consent.

When you visit a location-aware website, Firefox will ask you if you want to share your location.

If you consent, Firefox gathers information about nearby wireless access points and your computer’s IP address. Then Firefox sends this information to the default geolocation service provider, Google Location Services, to get an estimate of your location. That location estimate is then shared with the requesting website.

We are delighted to release the first build of Opera with geolocation support. The geolocation Working Group of the W3C has recently relased the first Working Draft of the geolocation API specification, and we are now releasing the first Labs build with support for the API.

The API is used in a web page's Javascript code to retrieve the current latitude and longitude of the browser.

Geolocation on the web is not new. Many sites already use the IP address of the browser to serve targetted content, mostly ads (you will have seen the 'Find a Friend in [your city]' banners). However, that method is notoriously inaccurate and cannot be reliably used for more advanced geolocation services. On the other hand, the device which the browser is running on is more likely to have an accurate idea of its location if it has a GPS unit or can triangulate the wireless access points or cell towers, or look up its IP address. Even if the device doesn't have the right hardware, a location provider web service can be used. This build uses the Skyhook service, and therefore you will need to register your site on loki.com in order for your geo-enabled web application to be allowed to request the locations of users. Additionally, if you're running Windows XP you will also need to run svcsetup.exe, which ensures that wifi scanning will not be affected by various "wifi managers" that are shipped with many laptops. All this won't be necessary in future releases, but for now if you experience crashes, it is likely because you need to run svcsetup.exe first.

Obtain the user's current position, using the getCurrentPosition method

Watch the user's position as it changes over time, using the watchPosition method

Quickly and cheaply obtain the user's last known position, using the lastPosition property

The Geolocation API provides the best estimate of the user's position using a number of sources (called location providers). These providers may be onboard (GPS for example) or server-based (a network location provider). The getCurrentPosition and watchPosition methods support an optional parameter of type PositionOptions which lets you specify which location providers to use.

The Gears Geolocation API can make use of network servers to obtain a position fix. The server determines the client's position using a set of data provided by the client. This data includes the client's IP address and information about any cell towers or WiFi nodes it can detect.

InfoQ asked Max Froumentin, core developer at Opera, about the future of Geolocation in the browser:

InfoQ: With native support shortly in both Firefox and Opera and the Google Gears plugin for other platforms, do you think that the usage of this API will become mainstream, even before having native implementations in platforms like IE? Do you think these will come soon?

Because geolocation is a very useful feature on the web, particularly on mobile devices, there will be applications written as soon as it is supported in browsers: website authors have been wanting this functionality for some time, and will be using it wherever it is available.

InfoQ: How do you think this API will be used? Do you think that it will just provide more capabilities to the contemporary types of applications or do you think it will enable a whole new genre?

Both. Obviously existing web sites that currently attempt geolocation (using IP or other approximate methods) will benefit from a far greater accuracy and will thus be able to provide a better service. But we can also trust people to come up with new and innovative applications making use of the new functionality offered by the API.

InfoQ: Do you feel that privacy considerations will make the transition to location-aware browsing slower?

Privacy concerns ought to make the transition slower: users should avoid using geolocation features in their browser unless they trust it to protect them and they trust websites to make good use of it. Just like any sensitive information people send to web sites (like credit card details), it's up to the location-enabled browsers to make sure that they get full control of their privacy by offering appropriate safeguards. Once those safeguards are in place, people will start making the transition.

What do you think, are the next generation web applications be location-aware by default?

Is your profile up-to-date? Please take a moment to review and update.

Email Address

Note: If updating/changing your email, a validation request will be sent

Company name:

Keep current company name

Update Company name to:

Company role:

Keep current company role

Update company role to:

Company size:

Keep current company Size

Update company size to:

Country/Zone:

Keep current country/zone

Update country/zone to:

State/Province/Region:

Keep current state/province/region

Update state/province/region to:

Subscribe to our newsletter?

Subscribe to our industry email notices?

You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.

We notice you're using an ad blocker

We understand why you use ad blockers. However to keep InfoQ free we need your support. InfoQ will not provide your data to third parties without individual opt-in consent. We only work with advertisers relevant to our readers. Please consider whitelisting us.