Skip to content

Instantly share code, notes, and snippets.

@aarong1
Created October 25, 2021 18:47
Show Gist options
  • Save aarong1/ee30481b2a0d999bbd0ef0bc8a44e3b0 to your computer and use it in GitHub Desktop.
Save aarong1/ee30481b2a0d999bbd0ef0bc8a44e3b0 to your computer and use it in GitHub Desktop.
boilerplate leaflet map in R
lgd_shape1$values <- plot$sum_pos[m]
#MAP-----
labels <- sprintf(
"<strong>%s</strong>:<br/>: %g ",
lgd_shape1$LGDNAME, plot$sum_pos[m]) %>%
lapply(htmltools::HTML)
#pal1 <- colorFactor("YlOrRd", domain = lgd_shape1$WARNING)
pal1 <- colorNumeric("YlOrRd", domain = plot$sum_pos[m])
map <- leaflet(lgd_shape1) %>%
addProviderTiles(providers$Stamen.Watercolor)%>%
addPolygons(
fillColor = ~pal1(values),
weight = 2,
opacity = 1,
color = "white",
dashArray = "3",
fillOpacity = 0.7,
highlight = highlightOptions(
weight = 5,
color = "black",
dashArray = "",
fillOpacity = 1,
bringToFront = TRUE),
label = labels,
labelOptions = labelOptions(
style = list("font-weight" = "normal", padding = "3px 8px"),
textsize = "15px",
direction = "auto"))
map%>%
addLegend(pal=pal1,
values=~values,
opacity = 0.7,
title = 'Severity',
position = "topright")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment