server_photo_s85js/public/js/map/layerManager.js
2026-08-11 08:45:04 +02:00

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