Update the style of a map
set_style.Rd
Update the style of a map
Arguments
- map
A map object created by the
mapboxgl
ormaplibre
function, or a proxy object.- style
The new style URL to be applied to the map.
- config
A named list of options to be passed to the style config.
- diff
A boolean that attempts a diff-based update rather than re-drawing the full style. Not available for all styles.
Examples
if (FALSE) { # \dontrun{
map <- mapboxgl(
style = mapbox_style("streets"),
center = c(-74.006, 40.7128),
zoom = 10,
access_token = "your_mapbox_access_token"
)
# Update the map style in a Shiny app
observeEvent(input$change_style, {
mapboxgl_proxy("map", session) %>%
set_style(mapbox_style("dark"), config = list(showLabels = FALSE), diff = TRUE)
})
} # }