The viz_minimap function adds a minimap inset to a geoviz map.
It displays a basemap and optionally highlights a location geometry (polygon or point).
This is useful for showing spatial context in map layouts.
NB: The map’s projection must provide an invert() function.
Usage
viz_minimap(
map,
id = NULL,
basemap_data = NULL,
basemap_fill = "white",
basemap_fillOpacity = 0.5,
basemap_stroke = "none",
width = 200,
projection = "EqualEarth",
precision = 10,
pos = c(10, 10),
location_type = "polygon",
location_r = 5,
location_fill = NULL,
location_stroke = NULL,
location_strokeWidth = 1.2,
domain = NULL,
margin = NULL,
...
)Arguments
- map
A
geovizmap created withviz_create.- id
character. Optional. Unique layer id. If NULL, a random id is generated.
- basemap_data
object. Optional. GeoJSON basemap. Default is
land.- basemap_fill
character. Optional. Fill color of the basemap (default "white").
- basemap_fillOpacity
numeric. Optional. Fill opacity of the basemap (default 0.5).
- basemap_stroke
character. Optional. Stroke color of the basemap (default "none").
- width
numeric. Optional. Width of the minimap (default 200).
- projection
character. Optional. Projection used for the minimap (default "EqualEarth").
- precision
numeric. Optional. Geometry simplification precision (default 10).
- pos
numeric vector. Optional. Position of the minimap (default c(10, 10)).
- location_type
character. Optional. Type of location geometry: "polygon" or "point" (default "polygon").
- location_r
numeric. Optional. Radius when location_type = "point" (default 5).
- location_fill
character. Optional. Fill color of the location geometry.
- location_stroke
character. Optional. Stroke color of the location geometry.
- location_strokeWidth
numeric. Optional. Stroke width of the location geometry (default 1.2).
- domain
list. Optional. Projection domain.
- margin
list. Optional. Margin configuration.
- ...
Additional styling options passed as prefixed arguments. Supported prefixes include:
outline_*for outline styling properties,basemap_*for basemap styling properties,location_*for location geometry styling properties.
Examples
library(sf)
world <- st_read(
system.file("gpkg/world.gpkg", package = "geoviz"),
quiet = TRUE
)
afr <- world[world$region== "Africa",]
viz_create(projection = "Mercator", background = "white", domain = afr) |>
viz_path(data = world, fill = "#9e9696") |>
viz_minimap(
width = 200,
projection = "EqualEarth",
pos = c(20, 20),
location_stroke = "red"
) |>
viz_render()