From 27aa2ed591212468d118059353866af1fc776631 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 26 Dec 2024 01:57:27 +0300 Subject: [PATCH] Move new note marker to click location If not done, it's possible to lose the marker when starting from low zooms. --- app/assets/javascripts/index/new_note.js | 8 ++++++++ 1 file changed, 8 insertions(+) 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"); -- 2.39.5