# NOT RUN {
library(leaflet)
data("quakes")
quakes <- quakes[1:100,]
numPal <- colorNumeric('viridis', quakes$depth)
sizes <- sizeNumeric(quakes$depth, baseSize = 10)
symbols <- Map(
makeSymbol,
shape = 'triangle',
color = numPal(quakes$depth),
width = sizes,
height = sizes
)
leaflet() %>%
addTiles() %>%
addMarkers(data = quakes,
icon = icons(iconUrl = symbols),
lat = ~lat, lng = ~long) %>%
addLegendSize(
values = quakes$depth,
pal = numPal,
title = 'Depth',
labelStyle = 'margin: auto;',
shape = c('triangle'),
orientation = c('vertical', 'horizontal'),
opacity = .7,
breaks = 5)
# a wrapper for making icons is provided
sizeSymbols <-
makeSizeIcons(
quakes$depth,
shape = 'cross',
pal = numPal,
color = 'black',
strokeWidth = 1,
opacity = .8,
fillOpacity = .5,
baseSize = 20
)
leaflet() %>%
addTiles() %>%
addMarkers(data = quakes,
icon = sizeSymbols,
lat = ~lat, lng = ~long) %>%
addLegendSize(
values = quakes$depth,
pal = numPal,
title = 'Depth',
shape = 'cross',
orientation = 'horizontal',
strokeWidth = 1,
opacity = .8,
fillOpacity = .5,
color = 'black',
baseSize = 20,
breaks = 5)
# }
Run the code above in your browser using DataLab