X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/ff52509d5a75c7f218a8d6d6d82bb25897b3dae9..c8f8dbca19f9f1ed3539f93e1785d4de70f2b093:/app/assets/javascripts/index/notes.js.erb?ds=sidebyside diff --git a/app/assets/javascripts/index/notes.js.erb b/app/assets/javascripts/index/notes.js.erb index ac73e1378..3a2a15393 100644 --- a/app/assets/javascripts/index/notes.js.erb +++ b/app/assets/javascripts/index/notes.js.erb @@ -1,9 +1,9 @@ //= require templates/notes/show //= require templates/notes/new -$(document).ready(function () { +function initializeNotes(map) { var params = OSM.mapParams(), - noteLayer = new L.LayerGroup(), + noteLayer = map.noteLayer, notes = {}, newNote; @@ -25,13 +25,6 @@ $(document).ready(function () { }) }; - layers.push({ - layer: noteLayer, - layerCode: "N" - }); - - map.noteLayer = noteLayer; - map.on("layeradd", function (e) { if (e.layer == noteLayer) { loadNotes(); @@ -57,8 +50,7 @@ $(document).ready(function () { }); if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') { - if (params.layers) setMapLayers(params.layers); - if (params.notes) map.addLayer(noteLayer); + if (params.notes || params.layers.indexOf('N') >= 0) map.addLayer(noteLayer); if (params.note) { $.ajax({ url: "/api/" + OSM.API_VERSION + "/notes/" + params.note + ".json", @@ -274,4 +266,4 @@ $(document).ready(function () { e.target.openPopup(); }); }); -}); +}