fix layer control

This commit is contained in:
vcoppe
2025-10-23 18:42:10 +02:00
parent 899dcddd2e
commit 76b3d09320

View File

@@ -10,6 +10,7 @@
import { map } from '$lib/components/map/map'; import { map } from '$lib/components/map/map';
import { customBasemapUpdate, getLayers } from './utils'; import { customBasemapUpdate, getLayers } from './utils';
import type { ImportSpecification, StyleSpecification } from 'mapbox-gl'; import type { ImportSpecification, StyleSpecification } from 'mapbox-gl';
import { untrack } from 'svelte';
let container: HTMLDivElement; let container: HTMLDivElement;
let overpassLayer: OverpassLayer; let overpassLayer: OverpassLayer;
@@ -50,7 +51,7 @@
$effect(() => { $effect(() => {
if ($map && ($currentBasemap || $customBasemapUpdate)) { if ($map && ($currentBasemap || $customBasemapUpdate)) {
setStyle(); untrack(() => setStyle());
} }
}); });
@@ -127,7 +128,7 @@
$effect(() => { $effect(() => {
if ($map && $currentOverlays && $opacities) { if ($map && $currentOverlays && $opacities) {
updateOverlays(); untrack(() => updateOverlays());
} }
}); });
@@ -137,7 +138,12 @@
} }
overpassLayer = new OverpassLayer(_map); overpassLayer = new OverpassLayer(_map);
overpassLayer.add(); overpassLayer.add();
_map.on('style.import.load', updateOverlays); let first = true;
_map.on('style.import.load', () => {
if (!first) return;
first = false;
updateOverlays();
});
}); });
let open = $state(false); let open = $state(false);