Skip to contents

Adds a distance scale bar to the map, wrapping MapLibre's native ScaleControl.

Usage

add_scale_control(
  map,
  id = "scale_control",
  max_width = 100,
  unit = c("metric", "imperial", "nautical"),
  position = "bottom-left"
)

Arguments

map

The map or map proxy object.

id

Unique identifier for the scale control. Default is "scale_control".

max_width

Maximum width, in pixels, of the scale control. Default is 80.

unit

Unit of measurement to display. One of "metric", "imperial", or "nautical". Default is "metric".

position

Position of the control on the map. Default is "bottom-left".

Value

The map or map proxy object for chaining.

Examples

map() |>
  add_scale_control()
map() |> add_scale_control(unit = "imperial", max_width = 100)