Skip to content

Failed redraw of SharedData layer #395

Closed
@cpsievert

Description

If you click "redraw" in this shiny app, then try to select markers, they are not highlighted, and I receive Uncaught TypeError: Cannot read property 'layer' of undefined

library(leaflet)
library(crosstalk)
library(shiny)

qd <- SharedData$new(quakes)

ui <- fluidPage(
  actionButton("redraw", "Redraw:"),
  leafletOutput("map")
)

server <- function(input, output, session) {
  
  output$map <- renderLeaflet({
    leaflet(qd) %>% 
      addTiles() %>% 
      addCircles(group = "foo")
  })
  
  observeEvent(input$redraw, {
    leafletProxy("map", session) %>%
      clearGroup("foo") %>%
      addMarkers(data = qd)
  })
  
}

shinyApp(ui, server)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions