mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-05-27 02:25:10 +00:00
fix loading initial style
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user