From: Anton Khorev Date: Tue, 14 Jan 2025 23:02:47 +0000 (+0300) Subject: Install add/remove event listeners directly on note layer X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/9d7e59784fe12856052ba8ca91b4a2400f83b11f Install add/remove event listeners directly on note layer --- diff --git a/app/assets/javascripts/index/layers/notes.js b/app/assets/javascripts/index/layers/notes.js index eaa5c3654..4676aa425 100644 --- a/app/assets/javascripts/index/layers/notes.js +++ b/app/assets/javascripts/index/layers/notes.js @@ -20,20 +20,14 @@ OSM.initializeNotesLayer = function (map) { }) }; - map.on("layeradd", function (e) { - if (e.layer === noteLayer) { - loadNotes(); - map.on("moveend", loadNotes); - } - }).on("layerremove", function (e) { - if (e.layer === noteLayer) { - map.off("moveend", loadNotes); - noteLayer.clearLayers(); - notes = {}; - } - }); - - noteLayer.on("click", function (e) { + noteLayer.on("add", () => { + loadNotes(); + map.on("moveend", loadNotes); + }).on("remove", () => { + map.off("moveend", loadNotes); + noteLayer.clearLayers(); + notes = {}; + }).on("click", function (e) { if (e.layer.id) { OSM.router.route("/note/" + e.layer.id); }