leaflet.multiopacity package for R

leaflet.multiopacity is the new package developed by Meantrix team. It provides an extension to the already known leaflet package for R, and allows the creation of an opacity control for multiple layers in one single widget.

This package was developed to supply the need for an opacity control which, first: works with the leafletProxy() function of leaflet package when rendering maps in a Shiny application, and second: works with more than one layer. However, it can be used in any leaflet map where an opacity control is needed, being a Shiny application, a R Markdown file or a single isolated map.

Take a look at some examples:

leaflet()
  addProviderTiles("OpenStreetMap", layerId = "base")
  addRasterImage(r, layerId = "rast")
  addAwesomeMarkers(lng = -2.79545, lat = 54.04321,
                    label = "Hospital", layerId = "hospital")
  addOpacityControls()
#> No filter used, showing all layers.
Click here for the interactive version.

The following case shows how to create controls for specific groups only. It is also possible to specify layerIds or categories (types of layers). Furthermore, it is possible to customize the control position and whether the control will be collapsible or not (and the icon size, in this case).

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"))
Click here for the interactive version.

The leaflet.multiopacity is already available on CRAN, and more info on usage and instructions can be found on its reference page: https://meantrix.github.io/leaflet.multiopacity/

2 thoughts on “leaflet.multiopacity package for R

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *