add_scale_control function

Add a scale control to a map

Add a scale control to a map

This function adds a scale control to a Mapbox GL or Maplibre GL map.

add_scale_control( map, position = "bottom-left", unit = "metric", max_width = 100 )

Arguments

  • map: A map object created by the mapboxgl or maplibre functions.
  • position: The position of the control. Can be one of "top-left", "top-right", "bottom-left", or "bottom-right". Default is "bottom-left".
  • unit: The unit of the scale. Can be either "imperial", "metric", or "nautical". Default is "metric".
  • max_width: The maximum length of the scale control in pixels. Default is 100.

Returns

The modified map object with the scale control added.

Examples

## Not run: library(mapgl) mapboxgl() |> add_scale_control(position = "bottom-right", unit = "imperial") ## End(Not run)
  • Maintainer: Kyle Walker
  • License: MIT + file LICENSE
  • Last published: 2025-03-18