Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix - remove source #180

Merged
merged 5 commits into from
Nov 14, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions app/src/app/constants/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export const INTERACTIVE_LAYERS = [BLOCK_HOVER_LAYER_ID, BLOCK_HOVER_LAYER_ID_CH

export const PARENT_LAYERS = [BLOCK_LAYER_ID, BLOCK_HOVER_LAYER_ID];

export const CHILD_LAYERS = [BLOCK_LAYER_ID_CHILD, BLOCK_HOVER_LAYER_ID_CHILD, BLOCK_LAYER_ID_HIGHLIGHT_CHILD];
export const CHILD_LAYERS = [
BLOCK_LAYER_ID_CHILD,
BLOCK_HOVER_LAYER_ID_CHILD,
BLOCK_LAYER_ID_HIGHLIGHT_CHILD,
];

export const DEFAULT_PAINT_STYLE: ExpressionSpecification = [
'case',
Expand Down Expand Up @@ -66,11 +70,11 @@ export function getLayerFill(
captiveIds?: Set<string>,
shatterIds?: Set<string>
): DataDrivenPropertyValueSpecification<number> {
const innerFillSpec = [
const innerFillSpec = ([
'case',
// is broken parent
['boolean', ['feature-state', 'broken'], false],
0,
0,
// geography is locked
['boolean', ['feature-state', 'locked'], false],
0.35,
Expand Down Expand Up @@ -108,7 +112,7 @@ export function getLayerFill(
['boolean', ['feature-state', 'hover'], false],
0.6,
0.2,
] as unknown as DataDrivenPropertyValueSpecification<number>;
] as unknown) as DataDrivenPropertyValueSpecification<number>;
if (captiveIds?.size) {
return [
'case',
Expand Down Expand Up @@ -162,12 +166,13 @@ export function getHighlightLayerSpecification(
'any',
['boolean', ['feature-state', 'focused'], false],
['boolean', ['feature-state', 'highlighted'], false],
['all',
[
'all',
// @ts-ignore correct logic, wrong types
['==', ['feature-state', 'zone'], null],
['boolean', !!highlightUnassigned],
['!', ['boolean', ['feature-state', 'broken'], false]],
]
],
],
3.5,
0, // Default width if none of the conditions are met
Expand Down Expand Up @@ -275,10 +280,13 @@ export function removeBlockLayers(map: Map | null) {
BLOCK_LAYER_ID_CHILD,
BLOCK_HOVER_LAYER_ID_CHILD,
BLOCK_LAYER_ID_HIGHLIGHT_CHILD,
BLOCK_SOURCE_ID,
].forEach(layer => {
map.getLayer(layer) && map.removeLayer(layer);
});

[BLOCK_SOURCE_ID].forEach(source => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual bugfix, rest is just prettier

map.getSource(source) && map.removeSource(source);
});
}

export {addBlockLayers};
Loading