aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-12 07:30:52 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-12 07:30:52 -0700
commit3eb1bb2e3f3d43cda2efe92754be4285dac6dbfd (patch)
tree974abf53abd89857a155e4e3ec44ccda176ddbe5
parent970df221bd7fb81d4d161ee91aa73cc56b05dfbe (diff)
downloadtrackermap-web-3eb1bb2e3f3d43cda2efe92754be4285dac6dbfd.tar.gz
trackermap-web-3eb1bb2e3f3d43cda2efe92754be4285dac6dbfd.tar.bz2
trackermap-web-3eb1bb2e3f3d43cda2efe92754be4285dac6dbfd.zip
Add OpenWeather overlay
-rw-r--r--modern/src/common/attributes/useCommonUserAttributes.js4
-rw-r--r--modern/src/map/overlay/useMapOverlays.js43
-rw-r--r--web/l10n/en.json6
3 files changed, 50 insertions, 3 deletions
diff --git a/modern/src/common/attributes/useCommonUserAttributes.js b/modern/src/common/attributes/useCommonUserAttributes.js
index ecb39daa..658f8668 100644
--- a/modern/src/common/attributes/useCommonUserAttributes.js
+++ b/modern/src/common/attributes/useCommonUserAttributes.js
@@ -17,6 +17,10 @@ export default (t) => useMemo(() => ({
name: t('mapBingKey'),
type: 'string',
},
+ openWeatherKey: {
+ name: t('mapOpenWeatherKey'),
+ type: 'string',
+ },
notificationTokens: {
name: t('attributeNotificationTokens'),
type: 'string',
diff --git a/modern/src/map/overlay/useMapOverlays.js b/modern/src/map/overlay/useMapOverlays.js
index ede1e5b9..1a917ba2 100644
--- a/modern/src/map/overlay/useMapOverlays.js
+++ b/modern/src/map/overlay/useMapOverlays.js
@@ -1,25 +1,62 @@
import { useSelector } from 'react-redux';
import { useTranslation } from '../../common/components/LocalizationProvider';
+import { useAttributePreference } from '../../common/util/preferences';
-const sourceCustom = (url) => ({
+const sourceCustom = (urls) => ({
type: 'raster',
- tiles: [url],
+ tiles: urls,
tileSize: 256,
});
export default () => {
const t = useTranslation();
+ const openWeatherKey = useAttributePreference('openWeatherKey');
const customMapOverlay = useSelector((state) => state.session.server?.overlayUrl);
return [
{
id: 'openSeaMap',
title: t('mapOpenSeaMap'),
- source: sourceCustom('http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png'),
+ source: sourceCustom(['http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png']),
available: true,
},
{
+ id: 'openWeatherClouds',
+ title: t('mapOpenWeatherClouds'),
+ source: sourceCustom([`https://tile.openweathermap.org/map/clouds_new/{z}/{x}/{y}.png?appid=${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}`]),
+ available: !!openWeatherKey,
+ attribute: 'openWeatherKey',
+ },
+ {
+ id: 'openWeatherPressure',
+ title: t('mapOpenWeatherPressure'),
+ source: sourceCustom([`https://tile.openweathermap.org/map/pressure_new/{z}/{x}/{y}.png?appid=${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}`]),
+ available: !!openWeatherKey,
+ attribute: 'openWeatherKey',
+ },
+ {
+ id: 'openWeatherTemperature',
+ title: t('mapOpenWeatherTemperature'),
+ source: sourceCustom([`https://tile.openweathermap.org/map/temp_new/{z}/{x}/{y}.png?appid=${openWeatherKey}`]),
+ available: !!openWeatherKey,
+ attribute: 'openWeatherKey',
+ },
+ {
id: 'custom',
title: t('mapOverlayCustom'),
source: sourceCustom(customMapOverlay),
diff --git a/web/l10n/en.json b/web/l10n/en.json
index 0ee4dc3f..f452ed0e 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -255,6 +255,12 @@
"mapOverlay": "Map Overlay",
"mapOverlayCustom": "Custom Overlay",
"mapOpenSeaMap": "OpenSeaMap",
+ "mapOpenWeatherKey": "OpenWeather API Key",
+ "mapOpenWeatherClouds": "OpenWeather Clouds",
+ "mapOpenWeatherPrecipitation": "OpenWeather Precipitation",
+ "mapOpenWeatherPressure": "OpenWeather Pressure",
+ "mapOpenWeatherWind": "OpenWeather Wind",
+ "mapOpenWeatherTemperature": "OpenWeather Temperature",
"mapLayer": "Map Layer",
"mapCustom": "Custom (XYZ)",
"mapCustomArcgis": "Custom (ArcGIS)",