addWMSLegend | R Documentation |
Add a WMS Legend
addWMSLegend(
map,
uri,
position = "topright",
layerId = NULL,
group = NULL,
title = "",
titleClass = "wms-legend-title",
titleStyle = ""
)
map |
a map widget object created from |
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. |
title |
A title that is prepended before the image. |
titleClass |
CSS-class for the title div |
titleStyle |
Style the title with CSS |
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(
title = "Personenschaden_5000", titleStyle = "font-size:1em; font-weight:800",
uri = paste0(
"https://www.wms.nrw.de/wms/unfallatlas?request=",
"GetLegendGraphic&version=1.3.0&",
"format=image/png&layer=Personenschaden_5000"
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.