Skip to content

Commit

Permalink
Move new note marker to click location
Browse files Browse the repository at this point in the history
If not done, it's possible to lose the marker when starting from low zooms.
  • Loading branch information
AntonKhorev committed Dec 31, 2024
1 parent 5603309 commit 27aa2ed
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/assets/javascripts/index/new_note.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() === "";
Expand Down Expand Up @@ -162,13 +168,15 @@ OSM.NewNote = function (map) {
});
});

map.on("click", moveNewNotMarkerToClick);
addNoteButton.on("disabled enabled", updateControls);
updateControls();

return map.getState();
};

page.unload = function () {
map.off("click", moveNewNotMarkerToClick);
addNoteButton.off("disabled enabled", updateControls);
removeNewNoteMarker();
addNoteButton.removeClass("active");
Expand Down

0 comments on commit 27aa2ed

Please sign in to comment.