Add a continuous legend
add_continuous_legend(
map,
legend_title,
values,
colors,
position = "top-left",
unique_id = NULL,
add = FALSE,
width = NULL,
layer_id = NULL,
margin_top = NULL,
margin_right = NULL,
margin_bottom = NULL,
margin_left = 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 (vector of stops).
The colors used to generate the color ramp.
The position of the legend on the map (one of "top-left", "bottom-left", "top-right", "bottom-right").
A unique ID for the legend container. Defaults to NULL.
Logical, whether to add this legend to existing legends (TRUE) or replace existing legends (FALSE). Default is FALSE.
The width of the legend. Can be specified in pixels (e.g., "250px") or as "auto". Default is NULL, which uses the built-in default.
The ID of the layer that this legend is associated with. If provided, the legend will be shown/hidden when the layer visibility is toggled.
Custom top margin in pixels, allowing for fine control over legend positioning. Default is NULL (uses standard positioning).
Custom right margin in pixels. Default is NULL.
Custom bottom margin in pixels. Default is NULL.
Custom left margin in pixels. Default is NULL.