Skip to content

Commit

Permalink
cleanup / CR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
zbigg committed May 7, 2024
1 parent e7350d0 commit 9291c3f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/api-reference/carto/fetch-map.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fetchMap({cartoMapId}).then(map => new Deck(map));
### Integration with CARTO basemaps

```js
fetchMap({cartoMapId}).then(({initialViewState, basemap, mapStyle, layers}) => {
fetchMap({cartoMapId}).then(({initialViewState, basemap, layers}) => {
const deckgl = new deck.DeckGL({
container: 'container',
controller: true,
Expand Down
14 changes: 4 additions & 10 deletions modules/carto/src/basemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,8 @@ export function applyCartoLayerGroupFilters(style, visibleLayerGroups: Record<st
};
}

function someLayersFilteredOut(visibleLayerGroups?: Record<string, boolean>) {
return (
visibleLayerGroups &&
Object.values(visibleLayerGroups).some(filteredOut => filteredOut === false)
);
function someLayerGroupsDisabled(visibleLayerGroups?: Record<string, boolean>) {
return visibleLayerGroups && Object.values(visibleLayerGroups).every(Boolean) === false;
}

export async function getCartoBasemapStyle({
Expand All @@ -75,7 +72,7 @@ export async function getCartoBasemapStyle({
const styleUrl = `${cartoBasemapsBaseUrl}/${styleType}-gl-style/style.json`;
let style = styleUrl;

if (visibleLayerGroups && someLayersFilteredOut(visibleLayerGroups)) {
if (visibleLayerGroups && someLayerGroupsDisabled(visibleLayerGroups)) {
try {
const originalStyle = await fetch(styleUrl, {
mode: 'cors',
Expand All @@ -84,10 +81,7 @@ export async function getCartoBasemapStyle({
style = applyCartoLayerGroupFilters(originalStyle, visibleLayerGroups);
} catch (error) {
// eslint-disable-next-line no-console
console.error(
'Error fetching CARTO basemap style, falling back to not-filtered style',
error
);
console.error('Error fetching CARTO basemap style, falling back to unfiltered style', error);
}
}
return style;
Expand Down

0 comments on commit 9291c3f

Please sign in to comment.