fix loading initial style

This commit is contained in:
vcoppe
2026-05-26 06:18:00 +02:00
parent 2fdb58bc7d
commit 0393a330a6
+5 -3
View File
@@ -66,10 +66,13 @@ export class StyleManager {
updateBasemap() { updateBasemap() {
const map_ = get(this._map); const map_ = get(this._map);
if (!map_) return; if (!map_) return;
this.buildStyle().then((style) => map_.setStyle(style)); let basemap = get(currentBasemap);
this.buildStyle(basemap).then((style) => {
if (get(currentBasemap) === basemap) map_.setStyle(style);
});
} }
async buildStyle(): Promise<maplibregl.StyleSpecification> { async buildStyle(basemap: string): Promise<maplibregl.StyleSpecification> {
const custom = get(customLayers); const custom = get(customLayers);
const style: maplibregl.StyleSpecification = { const style: maplibregl.StyleSpecification = {
@@ -83,7 +86,6 @@ export class StyleManager {
layers: [], layers: [],
}; };
let basemap = get(currentBasemap);
const basemapInfo = basemaps[basemap] ?? custom[basemap]?.value ?? basemaps[defaultBasemap]; const basemapInfo = basemaps[basemap] ?? custom[basemap]?.value ?? basemaps[defaultBasemap];
let basemapStyle = basemaps.openStreetMap as maplibregl.StyleSpecification; let basemapStyle = basemaps.openStreetMap as maplibregl.StyleSpecification;