I cannot figure out why clearshapes()
is not working in my leaflet shiny program. I am trying to remove the existing circles and replace with a category that is
Looks like there is an issue when filteredData()
is empty. You can trying adding an if/else:
if(nrow(filteredData())==0) { leafletProxy("map") %>% clearShapes()}
else {
leafletProxy("map", data = filteredData() ) %>% clearShapes() %>%
addCircles(radius = 1, color = "red", group = "circles")
}
Also if you want all the data points that have a selected Source
, you might want to use %in%
instead of ==
in your filtering:
df[as.character(df$Source) %in% input$set, ]