diff --git a/lib/OpenLayers/Control/Permalink.js b/lib/OpenLayers/Control/Permalink.js index 0c57a0a9b5..c8f6064b34 100644 --- a/lib/OpenLayers/Control/Permalink.js +++ b/lib/OpenLayers/Control/Permalink.js @@ -76,10 +76,25 @@ OpenLayers.Control.Permalink.prototype = */ updateLink: function() { var center = this.map.getCenter(); - var zoom = this.map.getZoom(); - var lat = Math.round(center.lat*100000)/100000; - var lon = Math.round(center.lon*100000)/100000; - this.element.href = this.base+"?lat="+lat+"&lon="+lon+"&zoom="+zoom; + var zoom = "zoom=" + this.map.getZoom(); + var lat = "lat=" + Math.round(center.lat*100000)/100000; + var lon = "lon=" + Math.round(center.lon*100000)/100000; + + var layers = "layers="; + var first = true; + for(var i=0; i< this.map.layers.length; i++) { + var layer = this.map.layers[i]; + if (layer.getVisibility()) { + if (!first) { + layers += ","; + } + layers += i; + first = false; + } + } + var href = this.base + "?" + lat + "&" + lon + "&" + + zoom + "&" + layers; + this.element.href = href; }, setCenter: function() { diff --git a/tests/test_Control_Permalink.html b/tests/test_Control_Permalink.html index caae86cc89..d8defe48ab 100644 --- a/tests/test_Control_Permalink.html +++ b/tests/test_Control_Permalink.html @@ -21,9 +21,9 @@ map.addControl(control); map.pan(5, 0); if (/MSIE/.test(navigator.userAgent)) { - t.eq($('permalink').href, "?lat=0&lon=1.75781&zoom=2", "Panning sets permalink"); + t.eq($('permalink').href, "?lat=0&lon=1.75781&zoom=2&layers=0", "Panning sets permalink"); } else { - t.eq($('permalink').href, location+"?lat=0&lon=1.75781&zoom=2", "Panning sets permalink"); + t.eq($('permalink').href, location+"?lat=0&lon=1.75781&zoom=2&layers=0", "Panning sets permalink"); } } function test_03_Control_Permalink_updateLinksBase (t) { @@ -37,7 +37,7 @@ if (!map.getCenter()) map.zoomToMaxExtent(); map.addControl(control); map.pan(5, 0); - $('edit_permalink').href = './edit.html?lat=0&lon=1.75781&zoom=2'; + $('edit_permalink').href = './edit.html?lat=0&lon=1.75781&zoom=2&layers=0'; t.eq($('permalink').href, $('edit_permalink').href, "Panning sets permalink with base"); } function test_04_Control_Permalink_noElement (t) {