InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Location-Aware Browsing to become Mainstream?

Posted by Dionysios G. Synodinos on May 23, 2009

Sections
Development
Topics
Rich Internet Apps ,
Java ,
Ruby ,
Javascript ,
.NET
Tags
W3C ,
Opera ,
Google Gears ,
Firefox

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?

Dionysios G. Synodinos is a Web Engineer and a freelance consultant, focusing on Web technologies

No comments

Watch Thread Reply

Educational Content

New-age Transactional Systems - Not Your Grandpa's OLTP

John Hugg discusses high volume transaction processing applications with high and low frequency profiles, and how VoltDB can be used for that purpose.

Cool Code

Kevlin Henney examines code samples to see what can be learned from them starting from the premise that one won’t write great code unless he knows how to read it.

Collaboration: At the Extremities of Extreme

Jason Ayers share the observations he made watching a team of developers collaborating in real time on the same code base, pushing XP, pair programming and continuous integration to their extremes.

Yesod Web Framework

Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).

Transactions without Transactions

Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.