Add a legend to a Mapbox GL map
add_legend(
map,
legend_title,
values,
colors,
type = c("continuous", "categorical"),
circular_patches = FALSE,
position = "top-left",
sizes = NULL
)
The updated map object with the legend added.
A map object created by the mapboxgl
function.
The title of the legend.
The values being represented on the map (either a vector of categories or a vector of stops).
The corresponding colors for the values (either a vector of colors, a single color, or an interpolate function).
One of "continuous" or "categorical".
Logical, whether to use circular patches in the legend (only for categorical legends).
The position of the legend on the map (one of "top-left", "bottom-left", "top-right", "bottom-right").
An optional numeric vector of sizes for the legend patches, or a single numeric value (only for categorical legends).