]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/new_note.js
Move new note marker to click location
[rails.git] / app / assets / javascripts / index / new_note.js
index 76d134ce6bd4de0d6282bb25d148451f8c6e96d7..885d7d2c994b22f5a35b27d1143b5df3254fa75e 100644 (file)
@@ -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");