Skip to content

FIX setAllBackgroundLayersVisibility#48

Open
xerc wants to merge 1 commit intoopengeos:mainfrom
xerc:patch-2
Open

FIX setAllBackgroundLayersVisibility#48
xerc wants to merge 1 commit intoopengeos:mainfrom
xerc:patch-2

Conversation

@xerc
Copy link
Copy Markdown
Contributor

@xerc xerc commented Apr 19, 2026

"(Show|Hide) All" buttons did to much :)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to fix the Background Legend “Show All / Hide All” behavior in LayerControl so it doesn’t toggle layers it shouldn’t.

Changes:

  • Updates setAllBackgroundLayersVisibility to use isExcludedByPattern when deciding which layers to toggle.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/core/LayerControl.ts Outdated

styleLayers.forEach(layer => {
if (!this.isUserAddedLayer(layer.id)) {
if (!this.isExcludedByPattern(layer.id)) {
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

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

setAllBackgroundLayersVisibility now applies visibility changes to all style layers except those matching excludeLayerPatterns. This diverges from populateBackgroundLayerList, which only treats layers as “background” when !isUserAddedLayer (and optionally excludes drawn layers / only-rendered filter). As written, clicking “Show All / Hide All” can unintentionally toggle user-added layers (and potentially custom/drawn layers) that are not part of the background legend, and may call setLayoutProperty on layer types that aren’t meant to be controlled here. Align the filtering logic with the background legend criteria (at minimum: gate on !isUserAddedLayer(layer.id) in addition to the pattern/drawn/rendered filters).

Suggested change
if (!this.isExcludedByPattern(layer.id)) {
if (!this.isExcludedByPattern(layer.id) && !this.isUserAddedLayer(layer.id)) {

Copilot uses AI. Check for mistakes.
@xerc
Copy link
Copy Markdown
Contributor Author

xerc commented Apr 19, 2026

@copilot ; how ybout make layers generic?; maplibre_gl_layer_control_child_layers_auto_api.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants