Add a legend with Awesome Icons
Usage
addLegendAwesomeIcon(
  map,
  iconSet,
  title = NULL,
  labelStyle = "",
  orientation = c("vertical", "horizontal"),
  marker = TRUE,
  group = NULL,
  className = "info legend leaflet-control",
  ...
)Arguments
- map
 a map widget object created from 'leaflet'
- iconSet
 a named list from awesomeIconList, the names will be the labels in the legend
- title
 the legend title, pass in HTML to style
- labelStyle
 character string of style argument for HTML text
- orientation
 stack the legend items vertically or horizontally
- marker
 whether to show the marker or only the icon
- group
 group name of a leaflet layer group
- className
 extra CSS class to append to the control, space separated
- ...
 arguments to pass to addControl
Value
an object from addControl
Examples
library(leaflet)
data(quakes)
iconSet <- awesomeIconList(
  `Font Awesome` = makeAwesomeIcon(icon = "font-awesome", library = "fa",
                                   iconColor = 'gold', markerColor = 'red',
                                   spin = FALSE,
                                   squareMarker = TRUE,
                                   iconRotate = 30,
  ),
  Ionic = makeAwesomeIcon(icon = "ionic", library = "ion",
                          iconColor = '#ffffff', markerColor = 'blue',
                          spin = TRUE,
                          squareMarker = FALSE),
  Glyphicon = makeAwesomeIcon(icon = "plus-sign", library = "glyphicon",
                              iconColor = 'rgb(192, 255, 0)',
                              markerColor = 'darkpurple',
                              spin = TRUE,
                              squareMarker = FALSE)
)
leaflet(quakes[1:3,]) %>%
  addTiles() %>%
  addAwesomeMarkers(lat = ~lat,
                    lng = ~long,
                    icon = iconSet) %>%
  addLegendAwesomeIcon(iconSet = iconSet,
                       orientation = 'horizontal',
                       title = htmltools::tags$div(
                         style = 'font-size: 20px;',
                         'Awesome Icons'),
                       labelStyle = 'font-size: 16px;') %>%
  addLegendAwesomeIcon(iconSet = iconSet,
                       orientation = 'vertical',
                       marker = FALSE,
                       title = htmltools::tags$div(
                         style = 'font-size: 20px;',
                         'Awesome Icons'),
                       labelStyle = 'font-size: 16px;')
