WIP: exit from building view (buggy)

This commit is contained in:
2026-09-15 11:38:53 +02:00
parent ace42261cf
commit 91b1764913
7 changed files with 83 additions and 14 deletions
+32
View File
@@ -0,0 +1,32 @@
import { Controller } from "@hotwired/stimulus"
import { GisState } from '../state.js';
export default class extends Controller {
static targets = ['bar'];
closeView(event) {
// Don't do anything if ESC keyboard event
// is not fired from the building view
if (event instanceof KeyboardEvent && !GisState.bViewActive) return;
this.resetMap();
this.barTarget.remove();
GisState.bViewActive = false;
}
resetMap() {
// Restore previous map state before closing view
const map = GisState.map;
map.removeLayer(GisState.baseLayers['Limiti amministrativi']);
map.removeLayer(GisState.cartography.buildings);
GisState.layers.walls.removeFrom(map);
map.addLayer(GisState.currentMapState.baseLayer);
map.setMinZoom(GisState.currentMapState.minZoom);
map.setMaxZoom(GisState.currentMapState.maxZoom);
map.setView(
GisState.currentMapState.center,
GisState.currentMapState.zoom
);
map._container.classList.remove('bview-border');
}
}