diff options
author | Anton Tananaev <anton@traccar.org> | 2024-03-14 17:27:38 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2024-03-14 17:27:38 -0700 |
commit | 7016950dac5988a55677f9773b7c6a4064ed9e46 (patch) | |
tree | 1b3aa1b2cf5c9ee1e108dda16e3e00fd735d41ad | |
parent | 5b1c7664dd8e750125ba697694dd407223c7c0d1 (diff) | |
download | trackermap-web-7016950dac5988a55677f9773b7c6a4064ed9e46.tar.gz trackermap-web-7016950dac5988a55677f9773b7c6a4064ed9e46.tar.bz2 trackermap-web-7016950dac5988a55677f9773b7c6a4064ed9e46.zip |
Fix map overlay flickering
-rw-r--r-- | modern/src/map/core/useMapStyles.js | 5 | ||||
-rw-r--r-- | modern/src/map/overlay/MapOverlay.js | 2 | ||||
-rw-r--r-- | modern/src/map/overlay/useMapOverlays.js | 5 |
3 files changed, 7 insertions, 5 deletions
diff --git a/modern/src/map/core/useMapStyles.js b/modern/src/map/core/useMapStyles.js index 733d8d33..7c3412b5 100644 --- a/modern/src/map/core/useMapStyles.js +++ b/modern/src/map/core/useMapStyles.js @@ -1,3 +1,4 @@ +import { useMemo } from 'react'; import { useSelector } from 'react-redux'; import { useTranslation } from '../../common/components/LocalizationProvider'; import { useAttributePreference } from '../../common/util/preferences'; @@ -37,7 +38,7 @@ export default () => { const mapboxAccessToken = useAttributePreference('mapboxAccessToken'); const customMapUrl = useSelector((state) => state.session.server.mapUrl); - return [ + return useMemo(() => [ { id: 'locationIqStreets', title: t('mapLocationIqStreets'), @@ -254,5 +255,5 @@ export default () => { }), available: !!customMapUrl, }, - ]; + ], [t, mapTilerKey, locationIqKey, bingMapsKey, tomTomKey, hereKey, mapboxAccessToken, customMapUrl]); }; diff --git a/modern/src/map/overlay/MapOverlay.js b/modern/src/map/overlay/MapOverlay.js index 4db2153d..e436ea8d 100644 --- a/modern/src/map/overlay/MapOverlay.js +++ b/modern/src/map/overlay/MapOverlay.js @@ -31,7 +31,7 @@ const MapOverlay = () => { map.removeSource(id); } }; - }); + }, [id, activeOverlay]); return null; }; diff --git a/modern/src/map/overlay/useMapOverlays.js b/modern/src/map/overlay/useMapOverlays.js index 5114424b..dafb5f83 100644 --- a/modern/src/map/overlay/useMapOverlays.js +++ b/modern/src/map/overlay/useMapOverlays.js @@ -1,3 +1,4 @@ +import { useMemo } from 'react'; import { useSelector } from 'react-redux'; import { useTranslation } from '../../common/components/LocalizationProvider'; import { useAttributePreference } from '../../common/util/preferences'; @@ -21,7 +22,7 @@ export default () => { const hereKey = useAttributePreference('hereKey'); const customMapOverlay = useSelector((state) => state.session.server.overlayUrl); - return [ + return useMemo(() => [ { id: 'openSeaMap', title: t('mapOpenSeaMap'), @@ -98,5 +99,5 @@ export default () => { source: sourceCustom(customMapOverlay), available: !!customMapOverlay, }, - ]; + ], [t, openWeatherKey, tomTomKey, hereKey, customMapOverlay]); }; |