From 927267d1116542f925205d087ca5e85429fdade1 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 dc269deef5..6cdec83205 100644 --- a/app/assets/javascripts/index/new_note.js +++ b/app/assets/javascripts/index/new_note.js @@ -105,6 +105,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() === ""; @@ -160,6 +166,7 @@ OSM.NewNote = function (map) { }); }); + map.on("click", moveNewNotMarkerToClick); addNoteButton.on("disabled enabled", updateControls); updateControls(); @@ -167,6 +174,7 @@ OSM.NewNote = function (map) { }; page.unload = function () { + map.off("click", moveNewNotMarkerToClick); addNoteButton.off("disabled enabled", updateControls); removeNewNoteMarker(); addNoteButton.removeClass("active");