diff options
author | Anton Tananaev <anton@traccar.org> | 2022-04-16 15:49:19 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-04-16 15:49:19 -0700 |
commit | b0f9aca5d820aae2094f72c56c59a1bee40f2edd (patch) | |
tree | 94705e9c226676690034cdaedaef7249c6133272 /modern/src/map | |
parent | 852cac23dcdfd6462c5bc83676291fa40e1f098e (diff) | |
download | trackermap-web-b0f9aca5d820aae2094f72c56c59a1bee40f2edd.tar.gz trackermap-web-b0f9aca5d820aae2094f72c56c59a1bee40f2edd.tar.bz2 trackermap-web-b0f9aca5d820aae2094f72c56c59a1bee40f2edd.zip |
Fix issue with vector maps (fix #910)
Diffstat (limited to 'modern/src/map')
-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'; |