Fix map overlay flickering

This commit is contained in:
Anton Tananaev 2024-03-14 17:27:38 -07:00
parent 5b1c7664dd
commit 7016950dac
3 changed files with 7 additions and 5 deletions

View File

@ -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]);
};

View File

@ -31,7 +31,7 @@ const MapOverlay = () => {
map.removeSource(id);
}
};
});
}, [id, activeOverlay]);
return null;
};

View File

@ -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]);
};