Install add/remove event listeners directly on note layer
This commit is contained in:
parent
914fff9d4d
commit
9d7e59784f
1 changed files with 8 additions and 14 deletions
|
@ -20,20 +20,14 @@ OSM.initializeNotesLayer = function (map) {
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
map.on("layeradd", function (e) {
|
noteLayer.on("add", () => {
|
||||||
if (e.layer === noteLayer) {
|
|
||||||
loadNotes();
|
loadNotes();
|
||||||
map.on("moveend", loadNotes);
|
map.on("moveend", loadNotes);
|
||||||
}
|
}).on("remove", () => {
|
||||||
}).on("layerremove", function (e) {
|
|
||||||
if (e.layer === noteLayer) {
|
|
||||||
map.off("moveend", loadNotes);
|
map.off("moveend", loadNotes);
|
||||||
noteLayer.clearLayers();
|
noteLayer.clearLayers();
|
||||||
notes = {};
|
notes = {};
|
||||||
}
|
}).on("click", function (e) {
|
||||||
});
|
|
||||||
|
|
||||||
noteLayer.on("click", function (e) {
|
|
||||||
if (e.layer.id) {
|
if (e.layer.id) {
|
||||||
OSM.router.route("/note/" + e.layer.id);
|
OSM.router.route("/note/" + e.layer.id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue