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
});
if (noteLoader) noteLoader.abort();
- noteLoader = $.ajax({
- url: url,
- success: success
- });
+ noteLoader = new AbortController();
+ fetch(url, { signal: noteLoader.signal })
+ .then(response => response.json())
+ .then(success)
+ .catch(() => {})
+ .finally(() => noteLoader = null);
}
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);
for (var id in oldNotes) {
noteLayer.removeLayer(oldNotes[id]);
}
-
- noteLoader = null;
}
}
};