leaflet.extras icon indicating copy to clipboard operation
leaflet.extras copied to clipboard

Feature request: new option in addGroupedLayersControl()

Open aloboa opened this issue 1 year ago • 1 comments

Using addGroupedLayersControl(), I can set the current groupedLayersControlOptions() in this way:

options = groupedLayersControlOptions(groupCheckboxes = TRUE,
                                        collapsed = FALSE,
                                        autoZIndex = TRUE,
                                        groupsCollapsable = FALSE,
                                        sortLayers = FALSE,
                                        sortGroups = FALSE,
                                        sortBaseLayers = FALSE,
                                        exclusiveGroups = "Miscelanea")) %>%

and get:

collapsedFALSE_groupsCollapsableFALSE

or:

options = groupedLayersControlOptions(groupCheckboxes = TRUE,
                                        collapsed = FALSE,
                                        autoZIndex = TRUE,
                                        groupsCollapsable = TRUE,
                                        sortLayers = FALSE,
                                        sortGroups = FALSE,
                                        sortBaseLayers = FALSE,
                                        exclusiveGroups = "Miscelanea")) %>%

and get:

collapsedFALSE_groupsCollapsableTRUE

But what I would like the user to see when opening the map is:

wish

which seems to me that would require an additional option "groupsCollapsed=FALSE"

aloboa avatar Sep 30 '24 08:09 aloboa

Unfortunately this is currently not supported in the underlying JS library. I will have to see how to include it there

trafficonese avatar Sep 30 '24 08:09 trafficonese

With this commit https://github.com/trafficonese/leaflet.extras/commit/921ec6960a7ffa0c910f443682793b595ec6deb7 you can now pass groupsCollapsed to groupedLayersControlOptions.

A logical, character string, or character vector: TRUE: Collapses all groups. FALSE (default): No groups are collapsed. A string: Collapses a single group (e.g., "Group 1"). A vector of strings: Collapses multiple groups (e.g., c("Group 1", "Group 2")).

trafficonese avatar Jan 13 '25 23:01 trafficonese