The viz_header function adds a title above a geoviz map.
Usage
viz_header(
map,
id = NULL,
text = "Map title",
fill = "#9e9696",
background_fill = "white",
background_stroke = "white",
background_strokeWidth = 1,
dominantBaseline = "central",
textAnchor = "middle",
lineSpacing = 0,
margin = 8,
fontSize = 26,
fontFamily = NULL,
dx = 0,
dy = 0,
...
)Arguments
- map
A
geovizmap created withviz_create.- id
character. Optional. Unique layer id.
- text
character. Optional. Title text to display (default "Map title").
- fill
character. Optional. Text color (default "#9e9696").
- background_fill
character. Optional. Background fill color (default "white").
- background_stroke
character. Optional. Background stroke color (default "white").
- background_strokeWidth
numeric. Optional. Background stroke width (default 1).
- dominantBaseline
character. Optional. Vertical text alignment. One of "hanging", "middle", "central", "bottom" (default "central").
- textAnchor
character. Optional. Horizontal text alignment. One of "start", "middle", "end" (default "middle").
- lineSpacing
numeric. Optional. Space between lines (default 0).
- margin
numeric. Optional. Margin around header (default 8).
- fontSize
numeric. Optional. Font size (default 26).
- fontFamily
character. Optional. Font family (default container font).
- dx
numeric. Optional. X offset (default 0).
- dy
numeric. Optional. Y offset (default 0).
- ...
Additional SVG attributes applied to the text or background elements.
Examples
library(sf)
world <- st_read(
system.file("gpkg/world.gpkg", package = "geoviz"),
quiet = TRUE
)
viz_create(projection = "EqualEarth", background = "white") |>
viz_path(datum = world, fill = "#f1f3f5") |>
viz_header(text = "Hello World", fill = "#38896F") |>
viz_render()