# NOT RUN {
## leaflet label display options
library(leaflet)
lopt = labelOptions(noHide = TRUE,
direction = 'top',
textOnly = TRUE)
## Add labels on a Leaflet map
indata <- sf::st_read(system.file("shape/nc.shp", package="sf"))
leaflet(indata) %>%
addProviderTiles("OpenStreetMap") %>%
addFeatures(.) %>%
addStaticLabels(., label = indata$NAME)
Modify styling -
leaflet(indata) %>%
addProviderTiles("OpenStreetMap") %>%
addFeatures(.) %>%
addStaticLabels(., label = indata$NAME,
style = list("color" = "red", "font-weight" = "bold"))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab