OpenStreetMap logo OpenStreetMap

OpenStreetMap-Geolocate.png

OpenStreetMap Geolocate is a user script that adds a "Geolocate me" link next to the OpenStreetMap.org search box. If your browser supports it and you've granted permission, clicking on this link will center your map window to your location, as reported by your browser via the HTML 5 geolocation API.

Say you've taken your laptop to a new cafe or conference—as soon as you open up OpenStreetMap, you can hit the "Geolocate me" link and quickly see what's around you, without fiddling with search or endlessly dragging the slippy map. Or, better yet, quickly add what's missing.

This definitely needs to be built into the OpenStreetMap website.

On most browsers, the geolocation API uses Google Location Services or Skyhook, which determine your location based on nearby wireless 802.11 access points. However, some browsers, like Firefox 3.6 on Linux, can talk to gpsd and your GPS unit, so geolocation can get quite accurate.

I've tested it on Firefox 3.6, Chrome 5, and Opera 10.60 (which, interestingly enough, is the first non-beta of Opera that supports geolocation). I've been told it also works on Safari 5.

I should make a note in the interest of accuracy: geolocation isn't actually part of "HTML 5"—it's a product of the W3C Geolocation Working Group. However, the need to be accurate didn't keep the XML out of AJAX, and by and far geolocation is one of the technologies people think about when they hear HTML5.

This entry is cross-posted on my blog.

Email icon Bluesky Icon Facebook Icon LinkedIn Icon Mastodon Icon Telegram Icon X Icon

Discussion

Comment from Andy Allan on 21 July 2010 at 08:30

Looks good. If you want to see it considered for the front page of osm.org you should consider filing an enhancement request at http://trac.openstreetmap.org (component 'website', or even better you can git clone the rails_port project and work on the code directly.

Comment from SamatJain on 21 July 2010 at 19:47

Andy: Thanks, I'll look into it! I wanted to start off with a user script to nail down browser compatibility (the first version of my code only worked with Firefox).

Log in to leave a comment