Skip to contents

Add a categorical legend

Usage

add_categorical_legend(
  map,
  legend_title,
  values,
  colors,
  circular_patches = FALSE,
  position = "top-left",
  unique_id = NULL
)

Arguments

map

A map object created by the mapboxgl function.

legend_title

The title of the legend.

values

The values being represented on the map (vector of categories).

colors

The corresponding colors for the values (vector of colors).

circular_patches

Logical, whether to use circular patches in the legend.

position

The position of the legend on the map (one of "top-left", "bottom-left", "top-right", "bottom-right").

unique_id

A unique ID for the legend container; defaults to NULL.

Value

The updated map object with the legend added.