Suggestion: icon markers
ThierryO opened this issue · comments
Leaflet provides icon markers. This would be nice to have in plotly.
Code taken from https://rstudio.github.io/leaflet/markers.html. That webpage contains the rendered output.
library(leaflet)
# Make a list of icons. We'll index into it based on name.
oceanIcons <- iconList(
ship = makeIcon("ferry-18.png", "ferry-18@2x.png", 18, 18),
pirate = makeIcon("danger-24.png", "danger-24@2x.png", 24, 24)
)
# Some fake data
df <- sp::SpatialPointsDataFrame(
cbind(
(runif(20) - .5) * 10 - 90.620130, # lng
(runif(20) - .5) * 3.8 + 25.638077 # lat
),
data.frame(type = factor(
ifelse(runif(20) > 0.75, "pirate", "ship"),
c("ship", "pirate")
))
)
leaflet(df) %>% addTiles() %>%
# Select from oceanIcons based on df$type
addMarkers(icon = ~oceanIcons[type])