BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Location-Aware Browsing to become Mainstream?

Location-Aware Browsing to become Mainstream?

Leia em Português

This item in japanese

With the W3C working on a specification that defines an API for providing scripted access to geographical location information, Mozilla recently announced built-in Geolocation support for Firefox 3.5. This is aligned with an earlier announcement from Opera that also adds support for Geolocation in their browser. Will this make geographically aware applications ubiquitous?

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:

Example of a "one-shot" position request.

function showMap(position) {
// Show a map centered at (position.coords.latitude, position.coords.longitude).
}
// One-shot position request.
navigator.geolocation.getCurrentPosition(showMap);

The draft spec also deals with the privacy considerations that arise:

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.

This powerful API will be made available natively in the next release of Firefox (3.5):

How does it work?

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.

If you say that you do not consent, Firefox will not do anything.

Opera has also announced a build that features Geolocation capabilities:

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.

For the rest of the browsers, there is Google Gears which offers the Geolocation API:

The Geolocation API enables a web application to:

  • 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.

Gears 0.5 will use WiFi antenna data to provide more accurate position data:

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?

Rate this Article

Adoption
Style

BT