W3C Geolocation support in Firefox

Nov 20, 2008

The W3C has created a standard for location sharing called Geolocation. It allows any person to share her location with any website at the click of a button. Imagine the possibilities with this.

Here is a scenario:

You’ve arrived in a new city, a new continent, a new coffee shop. You don’t really know where you are, and are looking for a good place to eat. You pull out your laptop, fire up Firefox, and go to your favorite review site. It automatically deduces your location, and serves up some delicious suggestions a couple blocks away and plots directions there.

Firefox 3.1 will have this build in, but until then we can use a Firefox add-on called Geode. Basically, it uses your Wi-Fi network to find your exact location and then passes it to a JavaScript callback method on your website. Already now, services like Pownce, Fire Eagle and ZYB uses this to improve the user experience of their services.

Here is a screenshot of what it looks like when Geode ask for a location:

Geode add-on

Getting started using Geode

You should start by downloading the Geode add-on for Firefox and make sure your Wi-Fi is turned on. Then fire up your HTML editor and add this JavaScript to one of your pages:

function geodeAsk()
{
 if (navigator.geolocation)
  navigator.geolocation.getCurrentPosition(geoFound, geoNotFound);
}

function geoFound(pos)
{
 var lat = pos.latitude;
 var lon = pos.longitude;
 alert(lat + ', ' + lon);
}

function geoNotFound()
{
 alert('You must be on a wifi network for us to determine your location');
}   

// Ask the browser for its location
geodeAsk();


Open the page in Firefox. Geode will now ask you if you want to share your location with the page. It’s that simple. Geode then sends the latitude and longitude to the JavaScript callback method and you can now do whatever you want with it. If you want to retrieve the address based on the location, then you need to do a simple reverse GEO lookup.

* Only $4.95/month ASP.NET & Windows 2008 + IIS 7 Hosting! FREE SQL Included

Comments (3) -

Kris Burgess
Kris Burgess United Kingdom
11/21/2008 7:56:03 AM #

Well I can see what you are saying here. But with use of GPS; mobile devices will offer the same and more functionality yet without having to carry a laptop around. You won't need to search a wi-fi spot out which is handy for places that dont offer this - mobiles will use HSDPA as standard.

On top of this - 2009 mobile devices will use "Radio frequency identification" - so using public transport could be done with a "swipe" of your phone (think the oyster card solution for london transport but transfer the tech to your phone instead).

Location based services is the next big thing! Expect to see a lot of business and solutions use/offer it for 2009 onwards...

Mads Kristensen
Mads Kristensen Denmark
11/21/2008 8:18:56 AM #

Actually, the Geolocation standard doesn't care where the browser get's the location info from. Right now Geode uses Wi-Fi, but GPS enabled phones will of course use that. It's up to the device/client to figure out the location, but the API from a web developers point of view is the same.

mobeamer
mobeamer United States
1/6/2009 2:56:18 PM #

I like the idea...could be used for a marketing aspect.

IE: I'm a game developer, so I could make a level in my game which is only available if you play while sitting in/near the Starbucks across the street from my house.

I then ask Starbucks for $10 a month for advertising. (LOL...not that they  would pay me)

But you get the idea.

Pingbacks and trackbacks (1)+

Comments are closed

About the author

Mads Kristensen

Mads Kristensen
Program Manager at the Microsoft Web Platform team and founder of BlogEngine.NET.

More...

Month List

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer’s view in any way.