From 0bad707fd781a665426926d19d9775a9b0cca90b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 1 Aug 2022 16:04:17 -0700 Subject: Fix map styles (fix #1004) --- modern/src/map/core/useMapStyles.js | 40 ++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'modern/src/map') 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(); -- cgit v1.2.3