Repository navigation
Conversation
GroupedLayerControl always passed `null` as the base layers argument of `L.control.groupedLayers`, so base layers could only go in a separate regular LayerControl (python-visualization#1876). An unknown `base_layers` keyword was also silently forwarded into the JS options. Add a `base_layers` argument: the given layers are rendered as the base layer radio buttons of the grouped control and get `control = False`, so they no longer also show up in a regular LayerControl. Which base layer is visible on opening still follows each layer's `show`, as with LayerControl. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
@adarshsm Looks good! Thanks for picking this up. |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1876.
The problem
GroupedLayerControlalways renderedL.control.groupedLayers(null, {...groups...}, options), so the base layers argument was alwaysnull. To get base layers you had to keep a regularLayerControlnext to the grouped one, which gives two separate controls. The issue asks for both in one control. The Leaflet plugin already supports this through its first argument, as @hansthen said in the issue.Passing
base_layers=today doesn't raise. It falls into**kwargsand ends up in the JS options object as"base_layers": [...], where the plugin ignores it.The change
base_layersargument (list of layers, defaultNone). The layers are rendered as the first argument ofL.control.groupedLayers({"name": layer, ...}). Withoutbase_layersthe output is unchanged (null).control = False, so a regularLayerControlon the same map doesn't list them a second time.show, the same as withLayerControl. Passshow=Falseto all but one base layer.Tests
test_grouped_layer_control_base_layerschecks the renderedL.control.groupedLayers({...base layers...}, {...groups...}, ...)call, and checks that a regularLayerControladded afterwards has no base layers left. It fails onmainand passes with this change.<script>blocks throughnode --checkto make sure the JS parses.pytest tests/plugins tests/test_map.py: 95 passed. The 2 failures (test_timedynamic_geo_jsonwithoutgeodatasets, andtest_icon_invalid_marker_colors) also fail on unmodifiedmainin my environment.black --checkandruff checkpass on the touched files.I haven't tested this in a browser.
🤖 Generated with Claude Code