diff --git a/website/src/lib/components/map/style.ts b/website/src/lib/components/map/style.ts index 7ff685666..d6cdac33e 100644 --- a/website/src/lib/components/map/style.ts +++ b/website/src/lib/components/map/style.ts @@ -66,10 +66,13 @@ export class StyleManager { updateBasemap() { const map_ = get(this._map); 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 { + async buildStyle(basemap: string): Promise { const custom = get(customLayers); const style: maplibregl.StyleSpecification = { @@ -83,7 +86,6 @@ export class StyleManager { layers: [], }; - let basemap = get(currentBasemap); const basemapInfo = basemaps[basemap] ?? custom[basemap]?.value ?? basemaps[defaultBasemap]; let basemapStyle = basemaps.openStreetMap as maplibregl.StyleSpecification;