R Shiny with leaflet: create a modal window on clicking an icon

Viewed 1629

I want to create a modal window when I click an icon in a leaflet map in shiny. Is this doable? I tried the code below, but the bsModal is not doing anything.

library(shiny)
library(leaflet)
library(shinyBS)

points <- data.frame(cbind(latitude = rnorm(40) * 2 + 13, longitude  = 
rnorm(40) + 48))


ui <- fluidPage(
  leafletOutput("mymap"),
    bsModal("modalExample", "This will open a modal", "assign_task", size = 
      "large",
    HTML(""))
    )

   server <- function(input, output, session) {



   output$mymap <- renderLeaflet({
   leaflet(options = leafletOptions(maxZoom = 18)) %>% addTiles() %>%
    addMarkers(lat = ~ latitude, lng = ~ longitude,
             data = points,
             popup=~ sprintf(
               '<button type="button" id="assign_task">Open Modal </button>'
             ))
   })
  }

shinyApp(ui, server)

enter image description here

1 Answers
Related