set_style | R Documentation |
Update the style of a map
set_style(map, style, config = NULL, diff = TRUE)
map |
A map object created by the |
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. |
The modified map object.
## Not run:
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)
})
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.