
Clear controls from a Mapbox GL or Maplibre GL map in a Shiny app
Source:R/controls.R
clear_controls.Rd
This function allows you to remove specific controls or all controls from a map.
You can target controls by their type names, which correspond to the function
names used to add them (e.g., "navigation" for controls added with add_navigation_control
).
Arguments
- map
A map object created by the
mapboxgl
ormaplibre
function.- controls
A character vector of control types to remove, or NULL to remove all controls. Control types include: "navigation", "draw", "fullscreen", "scale", "geolocate", "geocoder", "layers", "reset", "globe_minimap", or custom control IDs. If NULL (default), all controls will be removed.
Examples
if (FALSE) { # \dontrun{
library(shiny)
library(mapgl)
# Clear all controls
maplibre_proxy("map") |>
clear_controls()
# Clear specific controls
maplibre_proxy("map") |>
clear_controls("navigation")
# Clear multiple controls
maplibre_proxy("map") |>
clear_controls(c("draw", "navigation"))
# Clear a custom control by ID
maplibre_proxy("map") |>
clear_controls("my_custom_control")
} # }