diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-08-21 16:12:32 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-08-21 16:12:32 -0700 |
commit | be69f7ea8f58b65cfe164ac77ec5feb74755fb76 (patch) | |
tree | fff3971932d3bd1361bb66d7e32e93c9f76837e7 /modern/src/map/Map.js | |
parent | 946b6d807dc7625b02d4bd48de8da8682e3a3584 (diff) | |
download | trackermap-web-be69f7ea8f58b65cfe164ac77ec5feb74755fb76.tar.gz trackermap-web-be69f7ea8f58b65cfe164ac77ec5feb74755fb76.tar.bz2 trackermap-web-be69f7ea8f58b65cfe164ac77ec5feb74755fb76.zip |
Support MapTiler maps
Diffstat (limited to 'modern/src/map/Map.js')
-rw-r--r-- | modern/src/map/Map.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/modern/src/map/Map.js b/modern/src/map/Map.js index 7dd1c2a8..c2861ed5 100644 --- a/modern/src/map/Map.js +++ b/modern/src/map/Map.js @@ -7,7 +7,7 @@ import React, { import { SwitcherControl } from './switcher/switcher'; import deviceCategories from '../common/deviceCategories'; import { prepareIcon, loadImage } from './mapUtil'; -import { styleCarto, styleMapbox, styleOsm } from './mapStyles'; +import { styleCarto, styleMapbox, styleMapTiler, styleOsm } from './mapStyles'; import t from '../common/localization'; import { useAttributePreference } from '../common/preferences'; import palette from '../theme/palette'; @@ -64,13 +64,14 @@ map.addControl(new maplibregl.NavigationControl({ showCompass: false, })); -map.addControl(new SwitcherControl( +const switcher = new SwitcherControl( [ { title: t('mapOsm'), uri: styleOsm() }, { title: t('mapCarto'), uri: styleCarto() }, { title: t('mapMapboxStreets'), uri: styleMapbox('streets-v11') }, { title: t('mapMapboxOutdoors'), uri: styleMapbox('outdoors-v11') }, { title: t('mapMapboxSatellite'), uri: styleMapbox('satellite-v9') }, + { title: t('mapMapTilerBasic'), uri: styleMapTiler('basic', '${mapTilerKey}') }, ], t('mapOsm'), () => updateReadyValue(false), @@ -84,7 +85,9 @@ map.addControl(new SwitcherControl( }; waiting(); }, -)); +); + +map.addControl(switcher); const Map = ({ children }) => { const containerEl = useRef(null); @@ -97,6 +100,12 @@ const Map = ({ children }) => { maplibregl.accessToken = mapboxAccessToken; }, [mapboxAccessToken]); + const mapTilerKey = useAttributePreference('mapTilerKey'); + + useEffect(() => { + switcher.setVariable('mapTilerKey', mapTilerKey); + }, [mapTilerKey]); + useEffect(() => { const listener = (ready) => setMapReady(ready); addReadyListener(listener); |