X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/22d6633114d02af0e543afbb23cc05e33d1a1c9d..d0ed118ee24401a7e6117efa74522e67a9babba6:/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 54e0d5df7..81d6042c7 100644 --- a/app/assets/javascripts/index/notes.js.erb +++ b/app/assets/javascripts/index/notes.js.erb @@ -3,7 +3,7 @@ $(document).ready(function () { var params = OSM.mapParams(), - noteLayer = new L.LayerGroup(), + noteLayer = new L.LayerGroup({code: 'N'}), notes = {}, newNote; @@ -25,11 +25,6 @@ $(document).ready(function () { }) }; - layers.push({ - layer: noteLayer, - layerCode: "N" - }); - map.noteLayer = noteLayer; map.on("layeradd", function (e) { @@ -57,16 +52,13 @@ $(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", success: function (feature) { var marker = updateMarker(notes[feature.properties.id], feature); - notes[feature.properties.id] = marker; - map.addLayer(noteLayer); marker.openPopup(); } @@ -86,13 +78,11 @@ $(document).ready(function () { icon: noteIcons[feature.properties.status], opacity: 0.9 }); - marker.addTo(noteLayer).bindPopup( createPopupContent(marker, feature.properties), popupOptions() ); } - return marker; } @@ -115,9 +105,7 @@ $(document).ready(function () { function success(json) { var oldNotes = notes; - notes = {}; - json.features.forEach(updateMarkers); function updateMarkers(feature) { @@ -274,13 +262,9 @@ $(document).ready(function () { newNote.on("remove", function (e) { $("#createnoteanchor").removeClass("disabled").addClass("geolink"); - }); - - newNote.on("dragstart", function (e) { + }).on("dragstart", function (e) { $(newNote).stopTime("removenote"); - }); - - newNote.on("dragend", function (e) { + }).on("dragend", function (e) { e.target.openPopup(); }); });