X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/a661ee16931afe74866a57931c477ab8e0b35b05..2ce7060757ecfe242ddcb045084551b6bde21368:/app/assets/javascripts/index/new_note.js.erb diff --git a/app/assets/javascripts/index/new_note.js.erb b/app/assets/javascripts/index/new_note.js.erb index 7ac37ab72..95e38b2d3 100644 --- a/app/assets/javascripts/index/new_note.js.erb +++ b/app/assets/javascripts/index/new_note.js.erb @@ -3,7 +3,8 @@ OSM.NewNote = function(map) { content = $('#sidebar_content'), page = {}, addNoteButton = $(".control-note .control-button"), - newNote; + newNote, + halo; var noteIcons = { "new": L.icon({ @@ -79,6 +80,23 @@ OSM.NewNote = function(map) { OSM.loadSidebarContent(path, page.load); }; + function newHalo(loc, a) { + if (a == 'dragstart' && map.hasLayer(halo)) { + map.removeLayer(halo); + } else { + if (map.hasLayer(halo)) map.removeLayer(halo); + + halo = L.circleMarker(loc, { + weight: 2.5, + radius: 20, + fillOpacity: 0.5, + color: "#FF6200" + }); + + map.addLayer(halo); + } + } + page.load = function () { if (addNoteButton.hasClass("disabled")) return; if (addNoteButton.hasClass("active")) return; @@ -104,7 +122,13 @@ OSM.NewNote = function(map) { draggable: true }); + newNote.on("dragstart dragend", function(a) { + console.log(a); + newHalo(newNote.getLatLng(), a.type); + }); + newNote.addTo(noteLayer); + newHalo(newNote.getLatLng()); newNote.on("remove", function () { addNoteButton.removeClass("active"); @@ -130,6 +154,7 @@ OSM.NewNote = function(map) { page.unload = function () { noteLayer.removeLayer(newNote); + map.removeLayer(halo); addNoteButton.removeClass("active"); };