SIDEBAR
»
S
I
D
E
B
A
R
«
Bookmarklet to view OSM from coordinates parsed from URL
Aug 12th, 2016 by miki

Here’s a quick Javascript bookmarklet I threw together for opening a new browser window showing an area in OpenStreetMap that is defined from extracting the current window’s URL and searching after useable values for latitude, longitude and zoom.

It grew out of an annoyance over Mapillary’s rendering of the Danish endpoint of the under construction HVDC Cobra Cable(more about it from 4C, even more from EnergiNet and the EU) in Endrup nearby where I live.

In Mapillary’s tiles rendering it is just a bunch of roads and a single POI indication. Whereas the Mapnik rendering shows the existing power infrastructure and the area under construction.

Cobra HVDC, Endrup, Mapillary vs. OpenStreetMap

Well, I have been subjecting my oldstyle C brain to some Javascript lately so I decided to use that haemorrhage for attempting to put together a bookmarklet extracting coordinates from the current window’s URL and opening a new with the same approximate location in OSM.

It ended up like the below code block, and should also be usable on any other sites which receives locations via URL (both using HTTP GET notation with ‘?’ and locally in the page using anchors with ‘#’) and identifying them with key-value pairs using common names ({z,zoom},{lat},{lng,lon}). Note that this doesn’t include OpenStreetMap itself neither Google Maps as they only use the lat/lon values.

javascript:(function (){params={};kvs=document.location.href.split('&');kvs.forEach(function(kv){if(kv.indexOf('?'))kv=kv.substr(kv.indexOf('?')+1);if(kv.indexOf('#'))kv=kv.substr(kv.indexOf('#')+1);skv=kv.split('=');params[skv[0]]=skv[1];});window.open('http://openstreetmap.org/#map='+(params.z?params.z:13)+'/'+(params.lat?params.lat:55.5)+'/'+(params.lng?params.lng:(params.lon?params.lon:8.5)));console.log(params);})();

Copy and paste the above into the “Location” or “URL” of a bookmark and you’ll be able to click it to open a new OSM window on, at least for Mapillary maps pages, the same location as the original site. If nothing is found it will default to coordinates of my hometown of Esbjerg at 55.5/.8.5.

Here’s a prettified edition of the code:

params={};
kvs=document.location.href.split('&');
kvs.forEach(function(kv){
  if(kv.indexOf('?'))
    kv=kv.substr(kv.indexOf('?')+1);
  if(kv.indexOf('#'))
    kv=kv.substr(kv.indexOf('#')+1);
  skv=kv.split('=');
  params[skv[0]]=skv[1];
});
window.open( 'http://openstreetmap.org/#map='
            +(params.z?params.z:(params.zoom?params.zoom:13))+'/'
            +(params.lat?params.lat:55.5)+'/'
            +(params.lng?params.lng:(params.lon?params.lon:8.5))
           );
console.log(params);

Possible TODOs

  • get rid of default location, warn instead
  • support and test more sites (gmaps/osm!)
  • scan page contents for other geo markers
Street View Googling Denmark again
Aug 19th, 2010 by miki

Just saw the Google Street View car driving by at my daily whereabouts in Esbjerg, Denmark. Did get a little exhilerated and spilled some coffee in excitement and attempt to wave at the cameras (Hi mom!!) . Here’s a shot of the car taken by itself when passing my home at it’s last visit in 2009.

Apparently Google Streetview has started collecting data again here i Denmark, as they did in Norway, Sweden, Ireland and South Africa in July. Now with the Wi-Fi privacy issue resolved.

The following netfrenzy brought me to the official schedule at http://www.google.dk/help/maps/streetview/where-is-street-view.html which shows some mid to large sized cities in Denmark beeing up for an update, including Esbjerg. Strangely I haven’t noticed any lack of imagery in my local area. I know that most of Denmark was beeing photographed during July and August 2009, so something must be missing, or of inferior quality since they are coming back.

I also found a fun Street View Partner site; Legoland in California has allowed Street View to take a tour through the park. Fun for me, because the Lego Group HQ and original Legoland Billund is close to Esbjerg, and I have been going there regularly wiht the kids. Going to be fun to take them for a virtual walk in the park in California ;). The Billund park doesn’t seem to have been mapped internally, though.

Also a hilarious joke on Google Streetview from an interesting group of people; The Free Art and Technology (F.A.T.) Lab. Will be digging these nutty people out for sure.

»  Substance:WordPress   »  Style:Ahren Ahimsa
© 2016 Mikini Services