clear_drawn_features | R Documentation |
This function removes all features that have been drawn using the draw control on a Mapbox GL or MapLibre GL map in a Shiny application.
clear_drawn_features(map)
map |
A proxy object created by the |
The modified map object with all drawn features cleared.
## Not run:
# In a Shiny application
library(shiny)
library(mapgl)
ui <- fluidPage(
mapboxglOutput("map"),
actionButton("clear_btn", "Clear Drawn Features")
)
server <- function(input, output, session) {
output$map <- renderMapboxgl({
mapboxgl(
style = mapbox_style("streets"),
center = c(-74.50, 40),
zoom = 9
) |>
add_draw_control()
})
observeEvent(input$clear_btn, {
mapboxgl_proxy("map") |>
clear_drawn_features()
})
}
shinyApp(ui, server)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.