aboutsummaryrefslogtreecommitdiff
path: root/modern/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-21 07:54:39 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-21 07:54:39 -0700
commit9d97b19a0124755853d0b3fbb79a5be2061fafc8 (patch)
treec0aa540897897e814a5a28c6603e5c1c73c98501 /modern/src
parentab1fa14629c205f42a9a65817f2376b8a4f6636b (diff)
downloadtrackermap-web-9d97b19a0124755853d0b3fbb79a5be2061fafc8.tar.gz
trackermap-web-9d97b19a0124755853d0b3fbb79a5be2061fafc8.tar.bz2
trackermap-web-9d97b19a0124755853d0b3fbb79a5be2061fafc8.zip
Support custom map
Diffstat (limited to 'modern/src')
-rw-r--r--modern/src/map/core/Map.js7
1 files changed, 5 insertions, 2 deletions
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);