]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/5577'
authorTom Hughes <tom@compton.nu>
Wed, 29 Jan 2025 18:31:13 +0000 (18:31 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 29 Jan 2025 18:31:13 +0000 (18:31 +0000)
1  2 
app/assets/javascripts/index/layers/notes.js

index 1068472d5171bd0ab48c5ada2944be454ad79013,75bd73bcefa7eb4a97878e6223e6277636efee49..24bf969b3380581e9e3b07f35873b36a9fe6a170
@@@ -1,6 -1,7 +1,7 @@@
  OSM.initializeNotesLayer = function (map) {
-   var noteLayer = map.noteLayer,
-       notes = {};
+   let noteLoader;
+   const noteLayer = map.noteLayer;
+   let notes = {};
  
    var noteIcons = {
      "new": L.icon({
@@@ -25,6 -26,8 +26,8 @@@
      map.on("moveend", loadNotes);
      map.fire("overlayadd", { layer: noteLayer });
    }).on("remove", () => {
+     if (noteLoader) noteLoader.abort();
+     noteLoader = null;
      map.off("moveend", loadNotes);
      noteLayer.clearLayers();
      notes = {};
      if (marker) {
        marker.setIcon(noteIcons[feature.properties.status]);
      } else {
 +      let title;
 +      const description = feature.properties.comments[0];
 +
 +      if (description?.action === "opened") {
 +        title = description.text;
 +      }
 +
        marker = L.marker(feature.geometry.coordinates.reverse(), {
          icon: noteIcons[feature.properties.status],
 -        title: feature.properties.comments[0].text,
 +        title,
          opacity: 0.8,
          interactive: true
        });
@@@ -63,8 -59,6 +66,6 @@@
      return marker.id;
    };
  
-   var noteLoader;
    function loadNotes() {
      var bounds = map.getBounds();
      var size = bounds.getSize();