diff options
-rw-r--r-- | modern/src/map/Map.js | 20 | ||||
-rw-r--r-- | modern/src/map/switcher/switcher.js | 4 |
2 files changed, 14 insertions, 10 deletions
diff --git a/modern/src/map/Map.js b/modern/src/map/Map.js index b020423a..bbfe4764 100644 --- a/modern/src/map/Map.js +++ b/modern/src/map/Map.js @@ -68,14 +68,16 @@ map.addControl(new maplibregl.NavigationControl({ const switcher = new SwitcherControl( () => updateReadyValue(false), () => { - const waiting = () => { - if (!map.loaded()) { - setTimeout(waiting, 100); - } else { - initMap(); - } - }; - waiting(); + map.once('styledata', () => { + const waiting = () => { + if (!map.loaded()) { + setTimeout(waiting, 100); + } else { + initMap(); + } + }; + waiting(); + }); }, ); @@ -107,7 +109,7 @@ const Map = ({ children }) => { { id: 'mapboxSatellite', title: t('mapMapboxSatellite'), uri: styleMapbox('satellite-v9') }, { id: 'mapTilerBasic', title: t('mapMapTilerBasic'), uri: styleMapTiler('basic', mapTilerKey) }, { id: 'mapTilerHybrid', title: t('mapMapTilerHybrid'), uri: styleMapTiler('hybrid', mapTilerKey) }, - ], 'osm'); + ], 'locationIqStreets'); }, [mapTilerKey]); useEffect(() => { diff --git a/modern/src/map/switcher/switcher.js b/modern/src/map/switcher/switcher.js index 5fa62dcb..2c89faea 100644 --- a/modern/src/map/switcher/switcher.js +++ b/modern/src/map/switcher/switcher.js @@ -48,7 +48,9 @@ export class SwitcherControl { onSelectStyle(target) { this.onBeforeSwitch(); - this.map.setStyle(JSON.parse(target.dataset.uri)); + this.map.setStyle(JSON.parse(target.dataset.uri), { + diff: false, + }); this.mapStyleContainer.style.display = 'none'; this.styleButton.style.display = 'block'; |