Skip to contents

Add a control to a Map widget

Usage

add_control(
  .map,
  control_name = c("NavigationControl", "ScaleControl", "FullscreenControl",
    "GeolocateControl", "AttributionControl"),
  control_position = c("top-left", "top-right", "bottom-left", "bottom-right"),
  ...
)

Arguments

.map

A maplibre() HTML widget

control_name

The name of the control

control_position

The position of the control.

...

Control options depending on the type of control.

Value

The updated maplibre() HTML widget

Examples

map_options <- mapOptions(
  center = c(-123.1256, 49.24658),
  hash = TRUE,
  pitch = 0,
  style = basemaps$carto$dark_matter
  )

# add control uses add_call to add a control to the map widget
maplibre(map_options, zoom = 12) |>
  add_control("NavigationControl", "top-left", showCompass = FALSE)
# this is equal to: maplibre(map_options, zoom = 12) |> add_call("addControl", "NavigationControl", list(showCompass = FALSE), "top-left")