Zoomable state maps made with leaflet
mxstate_leaflet( df, pal, fillColor, popup, weight = 0.2, color = "#555555", opacity = 1, fillOpacity = 0.8, lng = -102, lat = 23.8, mapzoom = 5, zoom = NULL )
df | A data.frame with a column named "region" and a column named "value". Elements in the "region" column must exactly match how regions are named in the "region" column in ?df_mxstate. |
---|---|
pal | the color palette function, generated from
|
fillColor | the values used to generate colors from the palette function |
popup | The text to show when the user clicks on a map feature |
weight | The thickness of map feature borders |
color | The border color for the map features |
opacity | the opacity of colors. |
fillOpacity | The opacity of the colors used to fill the map features |
lng | The longitude of the map center |
lat | The latitude of the map center |
mapzoom | The zoom level |
zoom | The states to zoom into |
A leaflet map
if (FALSE) { library(scales) library(leaflet) data(df_mxstate) df_mxstate$value <- df_mxstate$afromexican / df_mxstate$pop pal <- colorNumeric("Blues", domain = df_mxstate$value) mxstate_leaflet(df_mxstate, pal, ~ pal(value), ~ sprintf("State: %s<br/>Value: %s", state_name, comma(value))) %>% addLegend(position = "bottomright", pal = pal, values = df_mxstate$value) %>% addProviderTiles("CartoDB.Positron") }