Produces an interactive leaflet map. Returns a leaflet object that can be extended with standard leaflet functions.
Arguments
- x
An sf object.
- fill
Character. Column name for choropleth fill. NULL produces an outline map.
- popup
Character vector. Column names to display in click popups.
- ...
Additional arguments passed to
leaflet::addPolygons().
Value
Returns a leaflet object (class "leaflet" and "htmlwidget") representing an interactive web map.
When fill = NULL, the output shows polygon outlines only.
When a fill variable is provided, the output renders polygons with:
- fillColor
Color-coded by the fill variable using the viridis palette
- fillOpacity
0.7 (semi-transparent for layer visibility)
- color
White borders for polygon boundaries
- popup
HTML popups showing selected attributes on click
The map includes a legend for the fill variable and uses the CartoDB.Positron tile provider as the basemap.
Examples
# \donttest{
districts <- get_districts()
pk_map_interactive(districts,
fill = "area_km2",
popup = c("district_name", "area_km2"))
# }