Ticket #3330: openstreetmap-geouri.diff

File openstreetmap-geouri.diff, 1.4 KB (added by steelman, 10 years ago)

geouri permalink on the map

  • app/views/site/index.html.erb

    diff --git a/app/views/site/index.html.erb b/app/views/site/index.html.erb
    index a892122..fcfcbcf 100644
    a b  
    2020</div>
    2121
    2222<div id="permalink">
    23   <a href="/" id="permalinkanchor"><%= t 'site.index.permalink' %></a><br/>
     23  <a href="/" id="permalinkanchor"><%= t 'site.index.permalink' %></a>
     24  (<a href="geo:0,0" id="geolinkanchor">GEO</a>)<br/>
    2425  <a href="/" id="shortlinkanchor"><%= t 'site.index.shortlink' %></a>
    2526</div>
    2627
  • public/javascripts/site.js

    diff --git a/public/javascripts/site.js b/public/javascripts/site.js
    index 0e2c5ae..4a48ad0 100644
    a b function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,obj 
    2525    node.href = setArgs(node.href, args);
    2626  }
    2727
     28  node = $("geolinkanchor");
     29  if (node) {
     30    var args = getArgs(node.href);
     31    // how accurately we click
     32    var pxunc = 3;
     33    // average Earth's circumference: 40041455 m
     34    // divide by 256 px at zoom 0
     35    var unc_0 = 156412;
     36
     37    // at zoom N unc_N = unc0 / 2^N
     38    unc = Math.round((pxunc * unc_0) / (1 << zoom));
     39    node.href = "geo:"+lat+
     40        ","+lon+";crs=wgs84"+          // is it WGS84???
     41        (unc > 5 ? ";u=" + unc : "")   // no GPS can do more
     42  }
     43
    2844  node = $("viewanchor");
    2945  if (node) {
    3046    var args = getArgs(node.href);