tomroh / leaflegend

Provides extensions to the leaflet R package to customize legends with images, text styling, orientation, sizing, and symbology.
https://leaflegend.delveds.com
Other
35 stars 3 forks source link

Allow Split Encodings for Size and Color #20

Closed tomroh closed 3 years ago

tomroh commented 3 years ago
numPal <- colorNumeric('viridis', quakes$depth)
symbols <- makeSizeIcons(
  values = exp(quakes$mag),
  shape = 'plus',
  color = 'black',
  baseSize = 10,
  fillColor = numPal(quakes$depth),
  opacity = .5
)

leaflet() %>%
  addTiles() %>%
  addMarkers(data = quakes,
             icon = icons(iconUrl = symbols),
             lat = ~lat, lng = ~long) %>%
  addLegendSize(
    values = quakes$mag,
    baseSize = 10,
    color = 'black',
    fillColor = 'black',
    title = 'Magnitude',
    shape = 'plus',
    orientation = 'horizontal',
    opacity = .5,
    fillOpacity = .3,
    breaks = 5) %>%
  addLegendNumeric(pal = numPal, values = quakes$depth, title = 'Depth')
tomroh commented 3 years ago

Use colorValues argument with a palette function.

d1ee8082c99925970e9156608c0690f01130e213