Refactor bview to Stimulus (mostly)

This commit is contained in:
2026-09-20 12:57:05 +02:00
parent cc590afa54
commit 5942cf37b4
6 changed files with 93 additions and 27 deletions
+6 -7
View File
@@ -102,7 +102,7 @@ GIS.initMap = async function (mapId, zoomLevel = this.INIT_ZOOM) {
// TEST: marker with SVG icon...
L.marker([40.5591380,14.2296069], { icon: Icons.wall, id: 'tiberio' })
.on('click', () => this.activateBuildingView('tiberio'))
.bindTooltip('Mappa USM')
.bindTooltip('Mappa di dettaglio interattiva')
.addTo(map);
GisState.map = map;
@@ -122,13 +122,14 @@ GIS.activateBuildingView = async function(layerId) {
const map = GisState.map;
saveCurrentState(map);
let currentBase = GisState.currentMapState.baseLayer;
const geometries = GisState.layers.geometries;
map.removeLayer(currentBase);
// Remove site layers then re-add it so vector lines
// are placed correctly above the new base map
GisState.layers.geometries.removeFrom(map);
geometries.removeFrom(map);
map.addLayer(GisState.baseLayers['Limiti amministrativi']);
GisState.layers.geometries.addTo(map);
geometries.addTo(map);
// TODO: move to function in Map module??
const wallLayers = [];
@@ -143,7 +144,6 @@ GIS.activateBuildingView = async function(layerId) {
wallLayer.addTo(map);
wallLayers.push(wallLayer);
}
catch {
continue;
@@ -159,9 +159,8 @@ GIS.activateBuildingView = async function(layerId) {
);
map.setMinZoom(this.BVIEW_MIN_ZOOM);
map.setMaxZoom(this.BVIEW_MAX_ZOOM);
// This is terrible...
UI.addBuildingViewBar();
map._container.classList.add('bview-active');
// Global event for Stimulus
document.dispatchEvent(new Event('bview-active'));
GisState.bViewActive = true;
}
/**