Skip to content

Commit d4a5c07

Browse files
zbiggfelixpalmer
authored andcommitted
carto: fix subLayerProps overriding in VectorTileLayer (#9075)
1 parent 8bd7ba6 commit d4a5c07

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

modules/carto/src/layers/vector-tile-layer.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,30 @@ export default class VectorTileLayer<
134134
const tileBbox = props.tile.bbox as any;
135135
const {west, south, east, north} = tileBbox;
136136

137+
const extensions = [new ClipExtension(), ...(props.extensions || [])];
137138
const clipProps = {
138-
extensions: [new ClipExtension(), ...(props.extensions || [])],
139139
clipBounds: [west, south, east, north]
140140
};
141141

142+
const applyClipExtensionToSublayerProps = (subLayerId: string) => {
143+
return {
144+
[subLayerId]: {
145+
...clipProps,
146+
...props?._subLayerProps?.[subLayerId],
147+
extensions: [...extensions, ...(props?._subLayerProps?.[subLayerId]?.extensions || [])]
148+
}
149+
};
150+
};
151+
142152
const subLayerProps = {
143153
...props,
144154
autoHighlight: false,
145155
// Do not perform clipping on points (#9059)
146156
_subLayerProps: {
147-
'polygons-fill': clipProps,
148-
'polygons-stroke': clipProps,
149-
linestrings: clipProps
157+
...props._subLayerProps,
158+
...applyClipExtensionToSublayerProps('polygons-fill'),
159+
...applyClipExtensionToSublayerProps('polygons-stroke'),
160+
...applyClipExtensionToSublayerProps('linestrings')
150161
}
151162
};
152163

0 commit comments

Comments
 (0)