Wednesday, September 15, 2010

The GPS you didn't know you had

The great thing about the internet is that you can find the answer to anything. You may not understand the answer, it may not even be the correct answer, but you can find it. And sometimes you will find out more than you were expecting.

Yesterday I happened to think "If I have a computer or smartphone with a GPS, can my position be accessed from its web browser?" A quick search of Google turned up the answer that yes, it could, in newer browsers that support HTML 5 like Firefox 3.6 and Google Chrome and the Android web browser. I even found some example code showing how to use it. I made a test page to try it out for myself. The results were a little unexpected.

First I tried it using my shack PC, which is a mini-tower with only a wired connection to my router. It told me that I was in Sheffield. This was actually not unexpected, as that is similar to the location I see when visiting some blogs that have a widget to show where visitors come from. I presume they, and the web browser, use geolocation by IP address if that is the only available method, and Sheffield is presumably the location of my broadband ISP's data centre.

When I tried using my smartphone running Android I saw the GPS status icon flicker on for a couple of seconds and my page then reported my position as being in Broughton, a village a couple of miles west of here. I'm guessing that the GPS didn't have time to get a good fix so I got a poor one, or else it is reporting the location of the cell the phone is connected to.

But the really surprising result was when I tried using my laptop. This doesn't have a GPS and is connected using wi-fi to my router, so it has the same IP address on the web as the shack system. Yet my test page pinpointed my location as across the street over the back, only about 20 yards from my actual location. I tried my netbook as well and got more or less the same position . How the heck did it know where I am?

After a bit more Googling I discovered that this is done by triangulating your position using the names or SSIDs of the wi-fi access points your computer can receive. A firm called Skyhook has created a database of access points and their locations by driving around every street in every town and city in the US. There is also a site called Geomena.org that has an access point database created by ordinary individuals. You can even add to it by installing a client app in your iPhone or Android phone and going walkabout. Google has a database which it presumably created at the same time it drove around doing Street View mapping and snooping on people's unsecured data. In Firefox you can see which wi-fi geolocation database is used by going to the address about:config (no http://) and examining the value of geo.wifi.uri. By default it's Google's. You can also disable browser geolocation by changing the value of geo.enabled.

I think the geolocation feature is pretty cool but I'm sure many privacy-obsessed types will be horrified by the thought that even without an actual GPS their position can be located to that kind of accuracy.

If you are interested in trying this for yourself then you can visit the Geolocation Test page that I created. If your browser supports geolocation (and you have Javascript turned on, which is necessary for the page to work) then you will be asked if you want to share your location with g4ilo.com. This is presumably a privacy thing, because if I wanted to I could log all the positions in a database. I don't, and in any case you're all hams so I can find out where you are from qrz.com, so hopefully you won't have a problem with that. If you allow the site to see your position it will then display your latitude, longitude and Maidenhead locator and show the position on a map so you can easily see if it is accurate.

If you do try my test page I'd be interested to know, via comments, how accurate the position was and whether your computer had a GPS, wi-fi or you were using a smartphone. If you have a mobile wi-fi device, does it track your position as you move around? If the results are promising I might make a permanent page for determining your grid locator using geolocation.

25 comments:

M0JEK said...

Just tested it from the London office using desktop PC and got;
Location: 51.51333° N 0.088947° W Locator: IO91wm
This is close, about a mile off.

I will try from home office later. I must say, this fun.

73 André

K9CHP said...

Hi Julian:
Using your Geolocation Test on my desktop computer, no GPS, no wi-fi, just able connection, it puts me about 10km from my home.

With my iPod Touch, wi-fi, no GPS, it uses the location I gave it, so it is within my neighborhood, but not my house.

With my Droid Incredible, running Froyo and GPS enabled and acquired, it said "position unavailable" although Java script is enabled...

Amir K9CHP

Ian said...

Just tried it from my work QTH which is in the middle of nowhere. It nailed it absolutely - I'd say less than 10 metres out.

Computer is a MacBook with WiFi, no GPS, connected to our work server via WiFi.

I also use the BlackBerry APRSBB app which sends my location via APRS-IS (G4FSU-5) using the GPS on my BlackBerry. That's also spot on, as I would expect.

73 Ian G4FSU

Sivan said...

Got a location about 30 meters outside my office, which I guess is reasonable, since at that point one can probably receive the same wifi network in both locations.

This is in Tel-Aviv University in Israel, on a laptop with no GPS and no cellular card, so it must have been done through wifi SSIDs.

Firefox did ask for permission to send out the location.

Sivan Toledo

Richard G3CWI said...

Within 50m. Home PC with WiFi connection

LeRoy Miller - KD8BXP said...

Off the desktop computer, no wifi - using Firefox & ubuntu 10.04 linux, it puts me in downtown Dayton, OHIO (35 miles give or take) But that is where the ISP is located, on my laptop (Jollicloud Linux, Chrome Browser, WIFI) It puts me within a half block of my house (Just outside the entrance to the community) - I was aware of this before I read your blog, but didn't put 2 and 2 together about the differences in WIFI connection & wired connection - may have to do some playing around with this, and see if things change if I change the SSID on the wifi router

LeRoy, KD8BXP

Philip said...

Looks to be spot on, probably to within 20m.
Apple laptop running Snow Leopard and wi-fi connection at home.
G6MDD

PE4BAS, Bas said...

Hi Julian, made 4 tests. 2 different browsers on my phone, but it seems they do not support Java, that's a pity as I do have GPS(any suggestion? it's a JAVA phone?). On the laptop with WiFi: 1 test with IE does show a location 15km away probabely the ISP location. And one test with Chrome does show spot on exactly my location. Very interesting....73, Bas

Bob said...

Using my laptop at home on home wi-fi using Opera browser less than 5 metres error, nearest public highway point to my wi-fi. Guess Google logged it when they mapped. Quite scary really.

Bob G3WKW

G4NKX said...

H i Julian:
Very Interesting - logged my Location as IO90kt (Central Portsmouth) app'x 6km west of me - this is the precise location when typed into "Google Maps" my actual Location is IO90MT I used a hard connection to my router from the desktop running Firefox 3.6.9 under Linux.

MrJoshua said...

Very, very close... Scary!!!

Rickyscouts said...

Hi Julian.

Got my position extremely close indeed and my Maidenhead locator was the one I normally use.

Used a PC running Puppy Linux 5.1.1 and Firefox 3.6.6, no GPS ever attached and no other location system ever used.

vk2rh said...

Within 80 metres of true location - here at work at QF56oc on 9th floor amid a sea of wifi on a MacBook Pro (Snow Leopard, Safari) with only a wifi link. iPad results identical. Reassuring and spooky at the same time!

Stephen said...

Ran it from my computer at work in Totton near Southampton. Told me my location was Glasgow. Must be Demon's datacentre, the supplier of the fibre link.

M0JEK said...

Run it again, from a laptop running Ubuntu connected to our works wifi while at our data centre on the 11th floor and was maybe 50 yds off. Pefect.

Rickyscouts said...

Run again on Iphone 3GS - perfect result, although I'm pretty certain it used the phones GPS.

Used it again on the company PC using Firefox 3.5.11 and it failed to get a location, but that's probably the Firefox version does not support it.

Incidentally, my first try (blogged here) was using my wireless router and I know we have had a Street Map "drive-by" so I guess the result may have come from Google.

Julian said...

Yep, the minimum Firefox for this is 3.6. IE 8 doesn't seem to support it either.

My newly dual boot smartphone running XDAndroid doesn't use the phone GPS. If I disable "use network location" and only leave GPS enabled I get "location unavailable." That may be because it's an Android hack. Hopefully someone with a real Android phone will try it.

Replying to Bas, PE4BAS comments, this is actually an HTML 5 feature, so you need an HTML 5 complianty browser. JavaScript (not Java, which is a separate thing) is needed on my page to display the result and show the Google map. But I presume someone could get this information without using JavaScript if they wanted to.

Paul - PAØPSY said...

Hi Julian, done. Follow the link: \
http://www.bitly.nl/f54cd5
The black arrow is where I live. 73 Paul

Andrew said...

Oddly I get "Position Unavailable" though I can use the "locate me" button on Google Maps with an accuracy of about 20m. The computer also sets its time zone automatically using a similar system and it gets the right town name (which is all the precision it offers).

I'm using Chrome under OSX connected to a wired network but with WiFi enables so it can use that if it feels.

Steve GW7AAV said...

Timeout! Every time?

LY2SS said...
This comment has been removed by the author.
LY2SS said...

Bit OT:

http://www.opencellid.org

73!

Bob said...

I just repeated the test with the wi-fi of the laptop off and cabled into the back of the same wireless router and I move 3 miles from Fleet into Aldershot. I am visiting OH land next week and wondering if to take the wi-fi router and see if that fools them!

Mike said...

Hi Julian, tested from desktop with WiFi, position is within a few metres (actually puts me in my next door neighbours garden !), the LOC is the one I use, 73 GM0DYU

Bob said...

So I flew 1000 miles and 2 time zones. Turned Wi-Fi off and plugged into father-in-laws ADSL and ran the test. It shows me slap bang in the town centre which is about 200 metres away. I turned the wi-fi on but still cable connected and repeat and I am now on the right street but 100 meters away. At this time I can see 2 networks which seems rather low for this location. 5 minutes later the location is spot on accurate! I can now see 3 wi-fi networks but am not connected to any of them! Next day i installed my wi-fi router fresh from home but the location remains solid, just around the corner this morning and bang on target now receiving from 5 or more other wi-fi. So it does not appear to be fooled by my router having been moved 1000 miles.