groupOptions: Set options on layer groups

View source: R/layers.R

groupOptionsR Documentation

Set options on layer groups


Change options on layer groups. Currently the only option is to control what zoom levels a layer group will be displayed at. The zoomLevels option is not compatible with layers control; do not both assign a group to zoom levels and use it with addLayersControl.


groupOptions(map, group, zoomLevels = NULL)



the map to modify


character vector of one or more group names to set options on


numeric vector of zoom levels at which group(s) should be visible, or TRUE to display at all zoom levels


pal <- colorQuantile("YlOrRd", quakes$mag)

leaflet() %>%
  # Basic markers
  addTiles(group = "basic") %>%
  addMarkers(data = quakes, group = "basic") %>%
  # When zoomed in, we'll show circles at the base of each marker whose
  # radius and color reflect the magnitude
  addProviderTiles(providers$Stamen.TonerLite, group = "detail") %>%
  addCircleMarkers(data = quakes, group = "detail", fillOpacity = 0.5,
    radius = ~mag * 5, color = ~pal(mag), stroke = FALSE) %>%
  # Set the detail group to only appear when zoomed in
  groupOptions("detail", zoomLevels = 7:18)

leaflet documentation built on May 29, 2024, 1:19 a.m.