From: Anton Khorev Date: Wed, 25 Dec 2024 22:57:27 +0000 (+0300) Subject: Move new note marker to click location X-Git-Tag: live~141^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/27aa2ed591212468d118059353866af1fc776631?ds=sidebyside Move new note marker to click location If not done, it's possible to lose the marker when starting from low zooms. --- diff --git a/app/assets/javascripts/index/new_note.js b/app/assets/javascripts/index/new_note.js index 76d134ce6..885d7d2c9 100644 --- a/app/assets/javascripts/index/new_note.js +++ b/app/assets/javascripts/index/new_note.js @@ -107,6 +107,12 @@ OSM.NewNote = function (map) { newNoteMarker = null; } + function moveNewNotMarkerToClick(e) { + if (newNoteMarker) newNoteMarker.setLatLng(e.latlng); + if (halo) halo.setLatLng(e.latlng); + content.find("textarea").focus(); + } + function updateControls() { const zoomedOut = addNoteButton.hasClass("disabled"); const withoutText = content.find("textarea").val() === ""; @@ -162,6 +168,7 @@ OSM.NewNote = function (map) { }); }); + map.on("click", moveNewNotMarkerToClick); addNoteButton.on("disabled enabled", updateControls); updateControls(); @@ -169,6 +176,7 @@ OSM.NewNote = function (map) { }; page.unload = function () { + map.off("click", moveNewNotMarkerToClick); addNoteButton.off("disabled enabled", updateControls); removeNewNoteMarker(); addNoteButton.removeClass("active");