I’m in your phone, watching you

While I was doing some reading on HTML5 geolocation on Friday, I noticed a method that I had missed previosuly – watchLocation.

While navigator.geolocation.getCurrentPosition will return the current position of the device, watchPosition fires off an event every time the device changes position. So, you can have real time updating using JavaScript within the browser.

I threw together a quick page to test this and it seems to work as expected. The slightly scary thing about it is that it continued to update in the browser even when I was using another app on my phone. The browser still had the page in memory even though I wasn’t using it anymore. Need to remember that one.

Anyway, the test code with source is available at http://kwilson.me/tracker if you want to have a play around with it. I’m not sending any location data back to the server, so I’m not tracking you directly. It’s all done in the JS on the phone.

Kevin Wilson

.NET developer, JavaScript enthusiast, Android user, Pebble wearer, sometime musician and occasional cook.

Leave a Reply

Your email address will not be published. Required fields are marked *