]> git.openstreetmap.org Git - rails.git/commitdiff
Add layers code to share link
authorTom MacWright <tom@macwright.org>
Thu, 13 Jun 2013 16:34:25 +0000 (12:34 -0400)
committerJohn Firebaugh <john.firebaugh@gmail.com>
Thu, 18 Jul 2013 17:45:15 +0000 (10:45 -0700)
app/assets/javascripts/application.js
app/assets/javascripts/index.js
app/assets/javascripts/leaflet.share.js

index e91a9036fd6973ce3ccbb12563b4826bd640b5aa..fc426e883551b150652133bbba912dd13fd1411a 100644 (file)
@@ -114,6 +114,10 @@ function updatelinks(loc, zoom, layers, bounds, object) {
   }
 }
 
   }
 }
 
+function minZoomAlert() {
+    alert(I18n.t("javascripts.site." + name + "_zoom_alert")); return false;
+}
+
 function getShortUrl(map) {
   return (window.location.hostname.match(/^www\.openstreetmap\.org/i) ?
           'http://osm.org/go/' : '/go/') +
 function getShortUrl(map) {
   return (window.location.hostname.match(/^www\.openstreetmap\.org/i) ?
           'http://osm.org/go/' : '/go/') +
@@ -129,14 +133,11 @@ function getUrl(map) {
         querystring.stringify({
             lat: center.lat,
             lon: center.lng,
         querystring.stringify({
             lat: center.lat,
             lon: center.lng,
-            zoom: zoom
+            zoom: zoom,
+            layers: map.getLayersCode()
         });
 }
 
         });
 }
 
-function minZoomAlert() {
-    alert(I18n.t("javascripts.site." + name + "_zoom_alert")); return false;
-}
-
 // Called to create a short code for the short link.
 function makeShortCode(map) {
     var zoom = map.getZoom(),
 // Called to create a short code for the short link.
 function makeShortCode(map) {
     var zoom = map.getZoom(),
@@ -175,6 +176,12 @@ function makeShortCode(map) {
     return str;
 }
 
     return str;
 }
 
+// generate a cookie-safe string of map state
+function cookieContent(map) {
+  var center = map.getCenter().wrap();
+  return [center.lng, center.lat, map.getZoom(), map.getLayersCode()].join('|');
+}
+
 /*
  * Forms which have been cached by rails may have the wrong
  * authenticity token, so patch up any forms with the correct
 /*
  * Forms which have been cached by rails may have the wrong
  * authenticity token, so patch up any forms with the correct
index d58317f63f8b12aaaa5c75c0dd12359984789174..7744b1ae4c15bc20b3ed9d08f61fb4deccd58671 100644 (file)
@@ -169,36 +169,10 @@ $(document).ready(function () {
   initializeNotes(map);
 });
 
   initializeNotes(map);
 });
 
-function getMapBaseLayerId(map) {
-  for (var i in map._layers) { // TODO: map.eachLayer
-    var layer = map._layers[i];
-    if (layer.options && layer.options.keyid) {
-      return layer.options.keyid;
-    }
-  }
-}
-
-function getMapLayers(map) {
-  var layerConfig = '';
-  for (var i in map._layers) { // TODO: map.eachLayer
-    var layer = map._layers[i];
-    if (layer.options && layer.options.code) {
-      layerConfig += layer.options.code;
-    }
-  }
-  return layerConfig;
-}
-
-// generate a cookie-safe string of map state
-function cookieContent(map) {
-  var center = map.getCenter().wrap();
-  return [center.lng, center.lat, map.getZoom(), getMapLayers(map)].join('|');
-}
-
 function updateLocation() {
   updatelinks(this.getCenter().wrap(),
       this.getZoom(),
 function updateLocation() {
   updatelinks(this.getCenter().wrap(),
       this.getZoom(),
-      getMapLayers(this),
+      this.getLayersCode(),
       this.getBounds().wrap(), {});
 
   var expiry = new Date();
       this.getBounds().wrap(), {});
 
   var expiry = new Date();
index 7efe12e0cb5feb4c785feed14626d0a89421a7c7..e97e29bb58ce8536d9ced0337b6a82624d4daee0 100644 (file)
@@ -58,8 +58,6 @@ L.OSM.share = function (options) {
     }
 
     function update() {
     }
 
     function update() {
-      var center = map.getCenter().wrap();
-      var layers = getMapLayers(map);
       $input.val(
           options.short ? options.getShortUrl(map) : options.getUrl(map)
       );
       $input.val(
           options.short ? options.getShortUrl(map) : options.getUrl(map)
       );