diff options
author | Anton Tananaev <anton@traccar.org> | 2022-08-01 16:04:17 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-08-01 16:04:17 -0700 |
commit | 0bad707fd781a665426926d19d9775a9b0cca90b (patch) | |
tree | 18bd389db50d217e754bfd76817ece71216366f1 /modern/src/map/core/useMapStyles.js | |
parent | 027f56866f4584debdef22792f0b9f1d7a545faf (diff) | |
download | trackermap-web-0bad707fd781a665426926d19d9775a9b0cca90b.tar.gz trackermap-web-0bad707fd781a665426926d19d9775a9b0cca90b.tar.bz2 trackermap-web-0bad707fd781a665426926d19d9775a9b0cca90b.zip |
Fix map styles (fix #1004)
Diffstat (limited to 'modern/src/map/core/useMapStyles.js')
-rw-r--r-- | modern/src/map/core/useMapStyles.js | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/modern/src/map/core/useMapStyles.js b/modern/src/map/core/useMapStyles.js index ba9ac5a6..affe89c2 100644 --- a/modern/src/map/core/useMapStyles.js +++ b/modern/src/map/core/useMapStyles.js @@ -2,25 +2,29 @@ import { useSelector } from 'react-redux'; import { useTranslation } from '../../common/components/LocalizationProvider'; import { useAttributePreference } from '../../common/util/preferences'; -const styleCustom = ({ tiles, minZoom, maxZoom, attribution }) => ({ - version: 8, - sources: { - custom: { - type: 'raster', - tiles, - attribution, - tileSize: 256, - minzoom: minZoom || 0, - maxzoom: maxZoom || 20, - }, - }, - glyphs: 'https://cdn.traccar.com/map/fonts/{fontstack}/{range}.pbf', - layers: [{ - id: 'custom', +const styleCustom = ({ tiles, minZoom, maxZoom, attribution }) => { + const source = { type: 'raster', - source: 'custom', - }], -}); + tiles, + attribution, + tileSize: 256, + minzoom: minZoom, + maxzoom: maxZoom, + }; + Object.keys(source).forEach((key) => source[key] === undefined && delete source[key]); + return { + version: 8, + sources: { + custom: source, + }, + glyphs: 'https://cdn.traccar.com/map/fonts/{fontstack}/{range}.pbf', + layers: [{ + id: 'custom', + type: 'raster', + source: 'custom', + }], + }; +}; export default () => { const t = useTranslation(); |