Skip to content

Commit

Permalink
fix(carto): Fix fetchMap visibleLayerGroup filtering to include stati…
Browse files Browse the repository at this point in the history
…c layers (#8915)
  • Loading branch information
zbigg authored May 22, 2024
1 parent 87ae695 commit 508649c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions modules/carto/src/basemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,17 @@ export function applyLayerGroupFilters(
return style;
}

const visibleFilters = STYLE_LAYER_GROUPS.filter(lg => visibleLayerGroups[lg.slug]).map(
const removedLayerFilters = STYLE_LAYER_GROUPS.filter(lg => !visibleLayerGroups[lg.slug]).map(
lg => lg.filter
);

const filteredLayers = style.layers.filter(layer => visibleFilters.some(match => match(layer)));
const visibleLayers = style.layers.filter(layer =>
removedLayerFilters.every(match => !match(layer))
);

return {
...style,
layers: filteredLayers
layers: visibleLayers
};
}

Expand Down
2 changes: 1 addition & 1 deletion test/modules/carto/api/basemap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const mockedMapConfig: KeplerMapConfig = {
};
const mockedCartoStyle = {
id: '1234',
layers: [{id: 'label'}, {id: 'road'}, {id: 'boundaries'}, {id: 'water'}]
layers: [{id: 'background'}, {id: 'label'}, {id: 'road'}, {id: 'boundaries'}, {id: 'water'}]
};
async function responseFunc(url: string) {
if (url === BASEMAP.VOYAGER) {
Expand Down

0 comments on commit 508649c

Please sign in to comment.