Manually specify icons, labels, and colours to add an Icon legend to a map.
Useful in conjunction with magicIcons()
to communicate the meaning of
icons/colours.
Usage
addIconLegend(
map,
icons,
labels,
colors = "black",
title = NULL,
library = "fontawesome",
position = c("topright", "bottomright", "bottomleft", "topleft"),
layerId = NULL,
className = "info legend",
data = leaflet::getMapData(map)
)
Arguments
- map
a map widget object created from
leaflet()
- icons
Name of the icons, passed to
fontawesome::fa()
orbsicons::bs_icon()
. A full list of available icons can be found usingfontawesome::fa_metadata()
, https://icons.getbootstrap.com/ or https://ionic.io/ionicons.- labels
Labels for each
icon
; should be the same length asicons
.- colors
Colours to use for each
icon
. Iflength(colors) == 1L
it is recycled for all icons. Otherwise should be the same length asicons
.- title
the legend title; optional.
- library
One of
"fontawesome"
,"bootstrap"
, or"ionicons"
, defining the icon library of interest. Defaults to"fontawesome"
.- position
position of control: "topleft", "topright", "bottomleft", or "bottomright"
- layerId
the layer id
- className
extra CSS classes to append to the control, space separated
- data
the data object from which the argument values are derived; by default, it is the
data
object provided toleaflet()
initially, but can be overridden
Value
a leaflet widget