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;
}
}
};