From 9d97b19a0124755853d0b3fbb79a5be2061fafc8 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 21 May 2022 07:54:39 -0700 Subject: Support custom map --- modern/src/map/core/Map.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'modern/src/map') diff --git a/modern/src/map/core/Map.js b/modern/src/map/core/Map.js index c328ba56..652d65c2 100644 --- a/modern/src/map/core/Map.js +++ b/modern/src/map/core/Map.js @@ -8,12 +8,13 @@ import { SwitcherControl } from '../switcher/switcher'; import deviceCategories from '../../common/util/deviceCategories'; import { prepareIcon, loadImage } from './mapUtil'; import { - styleCarto, styleLocationIq, styleMapbox, styleMapTiler, styleOsm, + styleCarto, styleCustom, styleLocationIq, styleMapbox, styleMapTiler, styleOsm, } from './mapStyles'; import { useAttributePreference } from '../../common/util/preferences'; import palette from '../../common/theme/palette'; import { useTranslation } from '../../common/components/LocalizationProvider'; import usePersistedState, { savePersistedState } from '../../common/util/usePersistedState'; +import { useSelector } from 'react-redux'; const element = document.createElement('div'); element.style.width = '100%'; @@ -96,6 +97,7 @@ const Map = ({ children }) => { const mapboxAccessToken = useAttributePreference('mapboxAccessToken'); const mapTilerKey = useAttributePreference('mapTilerKey'); const locationIqKey = useAttributePreference('locationIqKey', 'pk.0f147952a41c555a5b70614039fd148b'); + const customMapUrl = useSelector((state) => state.session.server?.mapUrl); useEffect(() => { maplibregl.accessToken = mapboxAccessToken; @@ -113,8 +115,9 @@ 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) }, + { id: 'custom', title: t('mapCustom'), uri: styleCustom(customMapUrl) }, ], defaultMapLayer); - }, [t, locationIqKey, mapTilerKey, defaultMapLayer]); + }, [t, locationIqKey, mapTilerKey, customMapUrl, defaultMapLayer]); useEffect(() => { const listener = (ready) => setMapReady(ready); -- cgit v1.2.3