Skip to contents

Mid-level builder: takes a MapModel (or a plain list with rows, resolution, ...) plus styling, assembles a MapLibreOption, and dispatches through draw(). Most users call draw_choropleth() instead.

Usage

draw_map(
  model,
  classification = "quantile",
  colormap = "blues",
  num_classes = 5,
  opacity = 1,
  show_boundaries = TRUE,
  outline_width = 0.2,
  show_legend = TRUE,
  legend_position = "bottom-right",
  tooltip_position = "top-right",
  title = NULL,
  theme = NULL,
  width = NULL,
  height = NULL,
  element_id = NULL,
  filename = NULL
)

Arguments

model

MapModel or named list: The choropleth data to render.

classification

Character {"quantile", "equal", "jenks"}: Class-break method. "quantile" (equal counts), "equal" (equal intervals), or "jenks" (natural breaks).

colormap

Character: Color ramp. One of the sequential schemes "blues", "viridis", "ylorrd", "greens", "magma", or the diverging schemes "rdbu", "rdylgn", "spectral", "brbg".

num_classes

Numeric [2, 12]: Number of color classes.

opacity

Numeric [0, 1]: Region fill opacity.

show_boundaries

Logical: Whether to draw region outlines.

outline_width

Numeric [0, Inf): Region outline width in pixels.

show_legend

Logical: Whether to show the legend.

legend_position

Character {"top-left", "top-right", "bottom-left", "bottom-right"}: Legend corner.

tooltip_position

Character {"top-left", "top-right", "bottom-left", "bottom-right"}: Hover tooltip corner.

title

Optional Character: Title (currently surfaced via the value label; reserved for future use).

theme

Optional Theme, list, or NA: Theme override. NULL enables light/dark auto-detection (matching draw()).

width

Optional Character or Numeric: Widget width.

height

Optional Character or Numeric: Widget height.

element_id

Optional Character: Explicit element ID.

filename

Optional Character: Static export of map widgets is not yet supported. Supplying a path raises an error.

Value

htmlwidget.

Examples

model <- MapModel(
  rows = list(
    MapRow(location = "USA", value = 25.5),
    MapRow(location = "CAN", value = 12.1)
  )
)
draw_map(model)