Zoomable municipio maps made with leaflet

mxmunicipio_leaflet(
  df,
  pal,
  fillColor,
  popup = "",
  weight = 0.2,
  color = "#555555",
  opacity = 0.8,
  fillOpacity = 0.8,
  lng = -102,
  lat = 23.8,
  mapzoom = 5,
  zoom = NULL
)

Arguments

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_mxmunicipio.

pal

the color palette function, generated from colorNumeric(), colorBin(), colorQuantile(), or colorFactor()

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 municipios to zoom into

Value

A leaflet map

Examples

if (FALSE) {
library(leaflet)

data(df_mxmunicipio)
df_mxmunicipio$value <- df_mxmunicipio$indigenous /df_mxmunicipio$pop
magma <- c("#000004FF", "#1D1146FF", "#50127CFF", "#822681FF",
           "#B63779FF", "#E65163FF", "#FB8761FF", "#FEC387FF", "#FCFDBFFF")
pal <- colorNumeric(magma, domain = df_mxmunicipio$value)
mxmunicipio_leaflet(df_mxmunicipio,
                    pal,
                    ~ pal(value),
                    ~ sprintf("State: %s<br/>Municipio : %s<br/>Value: %s%%",
                    state_name, municipio_name, round(value * 100, 1))) %>%
  addLegend(position = "bottomright", pal = pal,
            values = df_mxmunicipio$value) %>%
  addProviderTiles("CartoDB.Positron")
}