This package provides several ways to display opacity controls. The most basic use is calling
addOpacityControls() function without any argument.
Note that each function call has its own layerId. If you don’t provide a layerId for your layers, the opacity controls will still work, but will use the internal
_leaflet_id as a label for each control.
You can also customize some interface aspects such as box title, position, size and whether opacity controls will remain collapsed.
leaflet() %>% addProviderTiles("OpenStreetMap", layerId = "base") %>% addRasterImage(r, layerId = "rast") %>% addAwesomeMarkers(lng = -2.79545, lat = 54.04321, label = "Hospital", layerId = "hospital") %>% addOpacityControls(collapsed = TRUE, position = "topleft", size = "s") #> No filter used, showing all layers.
You can also define the subset of layers you want to show opacity controls to. You can provide the layerId of the layers to be shown.
Or the groups, if you have groups defined.
leaflet() %>% addProviderTiles("OpenStreetMap", layerId = "osm", group = "base") %>% addRasterImage(r, layerId = "rast", group = "rasters") %>% addAwesomeMarkers(lng = -2.79545, lat = 54.04321, layerId = "hospital", label = "hospital", group = "markers") %>% addOpacityControls(group = c("base", "rasters", "markers"))
Or even category. For example, if you want to show only rasters (category “image”) or markers (category “marker”), you could specify the categories as below.