I like to add and remove a drawtoolbar when toggling a button. But it does not work. Maybe a bug related to https://github.com/bhaskarvk/leaflet.extras/issues/148 or is something wrong with my code?
library(shiny)
library(shinyBS)
library(leaflet)
library(leaflet.extras)
ui <- fluidPage(
bsButton("edit", " Edit", icon = icon("pencil"),
style = "default", type = "toggle", value = FALSE),
leafletOutput("map")
)
server <- function(input, output, session) {
output$map <- renderLeaflet({leaflet() %>% addTiles()})
observe({
req(isFALSE(input$edit))
print(input$edit)
leafletProxy("map") %>% removeDrawToolbar()
})
observe({
req(isTRUE(input$edit))
print(input$edit)
leafletProxy("map") %>% addDrawToolbar()
})
}
shinyApp(ui, server)