From b7c171d2736140cfc8bbd30ae4911c8e52f5f07a Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Wed, 29 Jan 2025 18:13:10 +0300 Subject: [PATCH] Abort loading when note layer is removed --- app/assets/javascripts/index/layers/notes.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/index/layers/notes.js b/app/assets/javascripts/index/layers/notes.js index c0ba35d7e..75bd73bce 100644 --- a/app/assets/javascripts/index/layers/notes.js +++ b/app/assets/javascripts/index/layers/notes.js @@ -1,6 +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 @@ OSM.initializeNotesLayer = function (map) { map.on("moveend", loadNotes); map.fire("overlayadd", { layer: noteLayer }); }).on("remove", () => { + if (noteLoader) noteLoader.abort(); + noteLoader = null; map.off("moveend", loadNotes); noteLayer.clearLayers(); notes = {}; @@ -56,8 +59,6 @@ OSM.initializeNotesLayer = function (map) { return marker.id; }; - var noteLoader; - function loadNotes() { var bounds = map.getBounds(); var size = bounds.getSize(); -- 2.39.5