From 29433f9dea1aad1611ccc2a02b93aeb4eb1d0912 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 12 Jun 2022 07:56:31 -0700 Subject: Add TomTom map --- modern/src/map/core/useMapStyles.js | 8 ++++++++ modern/src/map/overlay/useMapOverlays.js | 14 +++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'modern/src/map') diff --git a/modern/src/map/core/useMapStyles.js b/modern/src/map/core/useMapStyles.js index 013772b3..963ffead 100644 --- a/modern/src/map/core/useMapStyles.js +++ b/modern/src/map/core/useMapStyles.js @@ -60,6 +60,7 @@ export default () => { const mapTilerKey = useAttributePreference('mapTilerKey'); const locationIqKey = useAttributePreference('locationIqKey'); const bingMapsKey = useAttributePreference('bingMapsKey'); + const tomTomKey = useAttributePreference('tomTomKey'); const customMapUrl = useSelector((state) => state.session.server?.mapUrl); return [ @@ -151,6 +152,13 @@ export default () => { available: !!bingMapsKey, attribute: 'bingMapsKey', }, + { + id: 'tomTomBasic', + title: t('mapTomTomBasic'), + uri: `https://api.tomtom.com/map/1/style/20.0.0-8/basic_main.json?key=${tomTomKey}`, + available: !!tomTomKey, + attribute: 'tomTomKey', + }, { id: 'custom', title: t('mapCustom'), diff --git a/modern/src/map/overlay/useMapOverlays.js b/modern/src/map/overlay/useMapOverlays.js index 1a917ba2..94baab3e 100644 --- a/modern/src/map/overlay/useMapOverlays.js +++ b/modern/src/map/overlay/useMapOverlays.js @@ -8,6 +8,10 @@ const sourceCustom = (urls) => ({ tileSize: 256, }); +const sourceOpenWeather = (style, key) => sourceCustom([ + `https://tile.openweathermap.org/map/${style}/{z}/{x}/{y}.png?appid=${key}`, +]); + export default () => { const t = useTranslation(); @@ -24,35 +28,35 @@ export default () => { { id: 'openWeatherClouds', title: t('mapOpenWeatherClouds'), - source: sourceCustom([`https://tile.openweathermap.org/map/clouds_new/{z}/{x}/{y}.png?appid=${openWeatherKey}`]), + source: sourceOpenWeather('clouds_new', 'openWeatherKey'), available: !!openWeatherKey, attribute: 'openWeatherKey', }, { id: 'openWeatherPrecipitation', title: t('mapOpenWeatherPrecipitation'), - source: sourceCustom([`https://tile.openweathermap.org/map/precipitation_new/{z}/{x}/{y}.png?appid=${openWeatherKey}`]), + source: sourceOpenWeather('precipitation_new', 'openWeatherKey'), available: !!openWeatherKey, attribute: 'openWeatherKey', }, { id: 'openWeatherPressure', title: t('mapOpenWeatherPressure'), - source: sourceCustom([`https://tile.openweathermap.org/map/pressure_new/{z}/{x}/{y}.png?appid=${openWeatherKey}`]), + source: sourceOpenWeather('pressure_new', 'openWeatherKey'), available: !!openWeatherKey, attribute: 'openWeatherKey', }, { id: 'openWeatherWind', title: t('mapOpenWeatherWind'), - source: sourceCustom([`https://tile.openweathermap.org/map/wind_new/{z}/{x}/{y}.png?appid=${openWeatherKey}`]), + source: sourceOpenWeather('wind_new', 'openWeatherKey'), available: !!openWeatherKey, attribute: 'openWeatherKey', }, { id: 'openWeatherTemperature', title: t('mapOpenWeatherTemperature'), - source: sourceCustom([`https://tile.openweathermap.org/map/temp_new/{z}/{x}/{y}.png?appid=${openWeatherKey}`]), + source: sourceOpenWeather('temp_new', 'openWeatherKey'), available: !!openWeatherKey, attribute: 'openWeatherKey', }, -- cgit v1.2.3