An interactive choropleth with hover and zoom, for dashboards and
R Markdown / Quarto. Engines are all optional Suggests.
Usage
interactive_map(
data,
fill,
tooltip = NULL,
engine = c("plotly", "ggiraph", "leaflet", "ggsql", "mapgl"),
...
)Arguments
- data
A map-ready frame (polygon or sf). The
"leaflet"engine will attach geometry itself if given a country-level table; the others require it already attached.- fill
The fill column (unquoted).
- tooltip
Optional tooltip column (unquoted).
- engine
"plotly"(default),"ggiraph","leaflet","mapgl"or"ggsql"."mapgl"renders through MapLibre GL – vector tiles, smooth zoom and a genuine interactive globe, which is what turnsglobe_map()from a static novelty into something you can turn. It needs ansfframe (database-side rendering to a Vega-Lite widget; needs ansfframe andggsql>= 0.4.1, the version that added theDRAW spatialclause).tooltipis honoured by the"ggiraph"and"leaflet"engines (defaults tofillwhen omitted);"plotly"'s hover is controlled byworld_map()aesthetics instead, and"ggsql"has no hover concept.- ...
Passed to
world_map()for the"plotly"engine, toworld_query()for"ggsql", and tomapgl::maplibre()for"mapgl". The"ggiraph"and"leaflet"engines assemble their own map and take no further arguments; they warn rather than ignore what they are given.
Examples
if (FALSE) { # \dontrun{
world_data(2020) |> interactive_map(gdp_per_capita)
world_data(2020, geometry = "sf") |>
interactive_map(gdp_per_capita, engine = "ggsql", transform = "log10")
} # }
