From: Tom Hughes Date: Wed, 8 May 2013 20:04:41 +0000 (+0100) Subject: Persist the state of the notes layer X-Git-Tag: live~5558 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/a7e67846a77722885b583a0f00ffe58b634e7eb3?ds=sidebyside;hp=427f896cdfcab441519e88afa41395ec2a06621a Persist the state of the notes layer --- diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 519a805bb..6118c8e0d 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -14,7 +14,7 @@ $(document).ready(function () { map.attributionControl.setPrefix(permalinks); - map.on("moveend baselayerchange", updateLocation); + map.on("moveend layeradd layerremove", updateLocation); if (!params.object_zoom) { if (params.bbox) { diff --git a/app/assets/javascripts/index/notes.js.erb b/app/assets/javascripts/index/notes.js.erb index f212c85b7..f414f0e34 100644 --- a/app/assets/javascripts/index/notes.js.erb +++ b/app/assets/javascripts/index/notes.js.erb @@ -26,6 +26,11 @@ $(document).ready(function () { var notes = {}; var newNote; + layers.push({ + layer: noteLayer, + layerCode: "N" + }); + map.on("layeradd", function (e) { if (e.layer == noteLayer) { loadNotes(); @@ -57,6 +62,7 @@ $(document).ready(function () { if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') { map.layersControl.addOverlay(noteLayer, I18n.t("browse.start_rjs.notes_layer_name")); + if (params.layers) setMapLayers(params.layers); if (params.notes) map.addLayer(noteLayer); if (params.note) { diff --git a/app/assets/javascripts/map.js.erb b/app/assets/javascripts/map.js.erb index 48fd35d0e..8591e260a 100644 --- a/app/assets/javascripts/map.js.erb +++ b/app/assets/javascripts/map.js.erb @@ -189,13 +189,13 @@ function getMapBaseLayer() { } function getMapLayers() { + var layerConfig = ""; for (var i = 0; i < layers.length; i++) { if (map.hasLayer(layers[i].layer)) { - return layers[i].layerCode; + layerConfig += layers[i].layerCode; } } - - return ""; + return layerConfig; } function setMapLayers(layerConfig) {