addWMSLegend {leaflet.extras}R Documentation

Add WMS Legend

Description

Add a WMS Legend

Usage

addWMSLegend(map, uri, position = "topright", layerId = NULL, group = NULL)

Arguments

map

a map widget object created from leaflet()

uri

The legend URI

position

the position of the legend

layerId

When the layerId of the WMS layer is properly set, the legend will appear or disappear accordingly based on whether the layer is visible or not. If no layerId is given, it will try to get the layer name from the 'uri', otherwise a random ID will be assigned.

group

The group argument is not used. Please set the 'layerId' correctly.

Examples

leaflet() %>%
  addTiles() %>%
  setView(11, 51, 6) %>%
  addWMSTiles(
    baseUrl = "https://www.wms.nrw.de/wms/unfallatlas?request=GetMap",
    layers = c("Unfallorte", "Personenschaden_5000", "Personenschaden_250"),
    options = WMSTileOptions(format = "image/png", transparent = TRUE)
  ) %>%
  addWMSLegend(
    uri = paste0(
      "https://www.wms.nrw.de/wms/unfallatlas?request=",
      "GetLegendGraphic&version=1.3.0&",
      "format=image/png&layer=Personenschaden_5000"
    )
  )

[Package leaflet.extras version 2.0.0 Index]