63 lines
735 B
JavaScript
63 lines
735 B
JavaScript
// public/js/map/layerManager.js
|
|
// ===============================
|
|
// GESTIONE GENERICA LAYER MARKER
|
|
// ===============================
|
|
|
|
(function () {
|
|
|
|
"use strict";
|
|
|
|
|
|
function sync(markerLayer, visibleMap, markers) {
|
|
|
|
const nextVisible = new Map();
|
|
|
|
|
|
for (const marker of markers) {
|
|
|
|
const id = marker.__item?.id;
|
|
|
|
if (!id) {
|
|
continue;
|
|
}
|
|
|
|
|
|
nextVisible.set(id, marker);
|
|
|
|
|
|
if (!visibleMap.has(id)) {
|
|
|
|
markerLayer.addLayer(marker);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const [id, marker] of visibleMap) {
|
|
|
|
if (!nextVisible.has(id)) {
|
|
|
|
markerLayer.removeLayer(marker);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
return nextVisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
window.MapLayerManager = {
|
|
|
|
sync
|
|
|
|
};
|
|
|
|
|
|
})();
|
|
|