I'm trying to filter markers on a map by using the Check Box Group Input.
titlePanel("Toronto Auto Thefts"),
leafletOutput ("map", width = "100%", height = "100%"),
absolutePanel(
checkboxGroupInput("checkGroup", h3("Week Day"),
choices = list("Monday" = 1,
"Tuesday" = 2,
"Wednesday" = 3,
"Thursday" = 4,
"Friday" = 5,
"Saturday" = 6,
"Sunday" = 7),
selected = 1))
)
The ui part seems ok because the check box is showing up appropriately.
server <- function(input, output, session){
#filtered <- reactive({data[data$occurrencedayofweek != input$checkGroup]})
output$map <- renderLeaflet({
leaflet(data = data) %>%
addTiles() %>%
addMarkers()
})
observe ({
proxy <- leafletProxy("map", data = data)
proxy %>% clearMarkers ()
if (data$occurrencedayofweek %in% input$checkGroup) {
proxy %>% addMarker()}
else {
proxy %>% clearMarkers() %>% clearControls()}
})
}
I believe it is the server that is causing problems, however I'm not sure how to fix it.