diff options
Diffstat (limited to 'modern')
-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(); |