# NOT RUN {
library(shiny)
ui <- fluidPage(
leafletOutput("map1")
)
server <- function(input, output, session) {
output$map1 <- renderLeaflet({
leaflet() %>% addCircleMarkers(
lng = runif(10),
lat = runif(10),
layerId = paste0("marker", 1:10))
})
observeEvent(input$map1_marker_click, {
leafletProxy("map1", session) %>%
removeMarker(input$map1_marker_click$id)
})
}
shinyApp(ui, server)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab