I am creating a map app with shiny. I'm looking for a way to delete a polygon created with addDrawToolbar using the actionButton placed on the sidebar. The sample code is as follows.
library(shiny)
library(leaflet)
library(leaflet.extras)
ui <- fluidPage(
titlePanel("ShinyApp"),
sidebarLayout(
sidebarPanel(
actionButton("delete","DELETE"),
),
mainPanel(
leafletOutput('maps')
)
)
)
server <- function(input, output, session) {
output$maps <- renderLeaflet({leaflet()%>%addTiles()%>%
addDrawToolbar(
targetGroup='draw',
editOptions = editToolbarOptions(selectedPathOptions = selectedPathOptions()),
rectangleOptions = F,
polylineOptions = F,
markerOptions = F,
circleOptions=F,
circleMarkerOptions=F)
})
observeEvent(input$delete, {
#process
leafletProxy("maps")%>%
removeDrawToolbar(clearFeatures=TRUE)
})
}
shinyApp(ui, server)
It is stated on the net that it can be deleted by using removeDrawToolbar (clearFeatures = TRUE)
, but it could not be realized.
If anyone knows or has a web page that can be used as a reference, I would be grateful if you could let me know.