By providing AJAX and Gears based geo-location

Aug 25, 2008 08:16 GMT  ·  By

Google has released two APIs to enhance geo-location. One is AJAX-based and the other one makes use of the Gears browser extension. This enables web and mobile developers to easily distribute content or to authenticate users based on location.

The AJAX API determines the location of a user based on their IP address. It works by populating the google.loader.ClientLocation property, which is part of the AJAX API Loader. The developers need an API key in order to use this service. A successful lookup will return latitude, longitude, city, country, country code and region. This can have multiple applications, like providing content based on location for news sites, local servers for download services, translated versions of content, user authentication etc. It also makes sending the data to other Google APIs, like the Google Maps or Google Feeds APIs, possible.

The AJAX-based geo-location is not perfect. Being based on the client IP, the lookup can fail, which would result in the property being null, but it does offer flexibility as the users do not need anything installed on their systems or within their browsers. This is not the case with Gears-based geo-location.

The Geolocation Module for the Gears API requires that users have the Gears extension installed in their browser. The Gears extension is available for Firefox 1.5 or higher, Internet Explorer 6 or higher, and Internet Explorer 4.01 or higher for the Windows Mobile operating system, while a version for Safari is in the works. While being less flexible, the Gears geo-location can provide more exact results, because it can use the "cell-ID of nearby cell towers or on-board GPS" data instead of just the IP address, with work being done to add the ability to use data from WiFi connections, which will further improve location fix.

The Gears Geolocation can do more than just determine the user's location, which is achieved through the getCurrentPosition() javascript function. It can also track position changes over time through watchPosition(). For privacy reasons, Google does not store any data regarding the location information, and users are given the option to allow or deny the attempt to determine their location for the first time. They can also modify this setting later.

The Gears extension and the Geolocation API are provided as open source, Gears Engineer Steve Block pointing out that they are making efforts "to work with existing and emerging standards." In this regard, he further explains, "Gears now implements the current editor's draft of the W3C Geolocation specification, which we've helped to define in collaboration with Microsoft, Mozilla, and others. We're committed to continued collaboration around the emerging HTML5 standard and the APIs specified by the W3C Web Applications Working Group."