leaflet
leaflet copied to clipboard
showGroup() doesn't work
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")

Deleted my post about overlayGroups, my bad: there was something wrong in my code. I still observe what @DagHjermann reported though.
All overlays are shown initially. If you want to only show Outline, you should hide Quakes.
This works for me:
map %>% hideGroup("Quakes")