diff --git a/packages/visualizations/src/components/MapPoi/utils.ts b/packages/visualizations/src/components/MapPoi/utils.ts index d832daaf..2f62d8a7 100644 --- a/packages/visualizations/src/components/MapPoi/utils.ts +++ b/packages/visualizations/src/components/MapPoi/utils.ts @@ -30,21 +30,31 @@ export const getMapLayers = (layers?: Layer[]): CircleLayerSpecification[] => { if (!layers) return []; return layers.map((layer) => { - let circleColor: DataDrivenPropertyValueSpecification | Color = layer.color; - // Border color is optionnal in map layers + const { + id, + type, + source, + sourceLayer, + circleRadius = 7, + circleStrokeWidth = 1.5, + colorMatch, + color: layerColor, + borderColor: layerBorderColor, + } = layer; + + let circleColor: DataDrivenPropertyValueSpecification | Color = layerColor; let circleBorderColor: DataDrivenPropertyValueSpecification | Color | undefined = - layer?.borderColor; + layerBorderColor; - if (layer.colorMatch) { - const { key, colors, borderColors } = layer.colorMatch; + if (colorMatch) { + const { key, colors, borderColors } = colorMatch; const groupByColors = ['match', ['get', key]]; Object.keys(colors).forEach((color) => { groupByColors.push(color, colors[color]); }); - groupByColors.push(layer.color); + groupByColors.push(layerColor); circleColor = groupByColors; - // Border colors are optionnal in the colorMatch props if (borderColors) { const groupBordersByColors = ['match', ['get', key]]; Object.keys(borderColors).forEach((borderColor) => { @@ -54,9 +64,6 @@ export const getMapLayers = (layers?: Layer[]): CircleLayerSpecification[] => { circleBorderColor = groupBordersByColors; } } - const { - id, type, source, sourceLayer, circleRadius = 7, circleStrokeWidth = 1.5 - } = layer; return { id, type,