Adds a polygon layer (fill + optional stroke). For data-driven fills, use a
color scale spec such as color_quantile() or color_factor().
Usage
add_polygons(
map,
data = NULL,
color = "darkblue",
opacity = 1,
width = 1,
fill_color = "dodgerblue",
fill_opacity = 0.6,
stroke = TRUE,
elevation = NULL,
elevation_scale = 1,
tooltip = NULL,
popup = NULL,
id = NULL,
group = NULL,
pickable = TRUE,
width_units = c("pixels", "meters", "common"),
width_min_pixels = NULL,
width_max_pixels = NULL
)Arguments
- map
A maplamina widget created by
maplamina().- data
Data for this layer. Typically an
sfobject with POLYGON/MULTIPOLYGON geometry.- color, opacity, width
Stroke color/opacity/width.
- fill_color, fill_opacity
Fill color/opacity.
fill_colorcan be a single color, a vector of colors, or a color scale spec such ascolor_quantile().- stroke
Logical; draw polygon stroke.
- elevation, elevation_scale
Optional extrusion height (numeric or formula) and scale.
- tooltip, popup
Optional
tmpl()objects (orNULL) for hover/click content.- id, group
Optional layer id and group name.
- pickable
Logical; whether features can be picked (tooltip/popup).
- width_units
Units for stroke
width; one of"pixels","meters", or"common".- width_min_pixels, width_max_pixels
Optional clamp in pixels when using meter/common units.
Examples
if (requireNamespace("sf", quietly = TRUE)) {
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
maplamina(nc) |>
add_polygons(fill_color = color_quantile(~BIR74), stroke = FALSE)
}