]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/layers/notes.js
Merge remote-tracking branch 'upstream/pull/5611'
[rails.git] / app / assets / javascripts / index / layers / notes.js
index 75bd73bcefa7eb4a97878e6223e6277636efee49..1bc3714f0472af0e9c9bd43c5621dd6750b7ebdc 100644 (file)
@@ -43,9 +43,16 @@ OSM.initializeNotesLayer = function (map) {
     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
       });
@@ -77,9 +84,7 @@ OSM.initializeNotesLayer = function (map) {
     function success(json) {
       var oldNotes = notes;
       notes = {};
-      json.features.forEach(updateMarkers);
-
-      function updateMarkers(feature) {
+      for (const feature of json.features) {
         var marker = oldNotes[feature.properties.id];
         delete oldNotes[feature.properties.id];
         notes[feature.properties.id] = updateMarker(marker, feature);