powered by
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 )
The modified map object with the scale control added.
A map object created by the mapboxgl or maplibre functions.
mapboxgl
maplibre
The position of the control. Can be one of "top-left", "top-right", "bottom-left", or "bottom-right". Default is "bottom-left".
The unit of the scale. Can be either "imperial", "metric", or "nautical". Default is "metric".
The maximum length of the scale control in pixels. Default is 100.
if (FALSE) { library(mapgl) mapboxgl() |> add_scale_control(position = "bottom-right", unit = "imperial") }
Run the code above in your browser using DataLab