leaflet icon indicating copy to clipboard operation
leaflet copied to clipboard

showGroup() doesn't work

Open DagHjermann opened this issue 5 years ago • 2 comments

showGroup() doesn't work for the time being. Instead of showing just the indicated groups, all groups are shown. (hideGroup() still works though.) I have tried to install the latest Github version of leaflet (2.0.2) and that doesn't help.

library(leaflet)                                                      
                                                                      
outline <- quakes[chull(quakes$long, quakes$lat),]                    
                                                                      
map <- leaflet(quakes) %>%                                            
# Base groups                                                         
addTiles(group = "OSM (default)") %>%                                 
addProviderTiles(providers$Stamen.Toner, group = "Toner") %>%         
addProviderTiles(providers$Stamen.TonerLite, group = "Toner Lite") %>%
# Overlay groups                                                      
addCircles(~long, ~lat, ~10^mag/5, stroke = F, group = "Quakes") %>%  
addPolygons(data = outline, lng = ~long, lat = ~lat,                  
fill = F, weight = 2, color = "#FFFFCC", group = "Outline") %>%       
# Layers control                                                      
addLayersControl(                                                     
baseGroups = c("OSM (default)", "Toner", "Toner Lite"),               
overlayGroups = c("Quakes", "Outline"),                               
options = layersControlOptions(collapsed = FALSE)                     
)                                                                     
                                                                      
# Try to show only the 'Outline' group:
map %>% showGroup("Outline")                                          

DagHjermann avatar Nov 14 '19 10:11 DagHjermann

Deleted my post about overlayGroups, my bad: there was something wrong in my code. I still observe what @DagHjermann reported though.

Kabouik avatar Dec 13 '19 16:12 Kabouik

All overlays are shown initially. If you want to only show Outline, you should hide Quakes. This works for me: map %>% hideGroup("Quakes")

trafficonese avatar Aug 27 '20 10:08 trafficonese