I am trying to combine 4 leaflet maps into one, where you can filter the layers using addLayerControl. Each layer has popups when you hover over the polygon with the corresponding variable (numeric) and legend. When I try to add them together the control appears, but choosing different filters doesn't change anything on the map. Am i doing this correctly? Thanks so much!
data %>%
leaflet %>%
addProviderTiles("CartoDB.PositronNoLabels") %>%
addPolygons(weight = 1, stroke = TRUE, color = "black", fillColor = ~pal2(data$variable_tertile), label = ~paste0("SCORE: ", variable)) %>%
addLegend("bottomright", pal = pal2, values = ~variable_tertile, title = "") %>%
addProviderTiles("CartoDB.PositronNoLabels") %>%
addPolygons(weight = 1, stroke = TRUE, color = "black", fillColor = ~pal2(data$variable_tertile), label = ~paste0("SCORE: ", variable)) %>%
addLegend("bottomright", pal = pal2, values = ~variable_tertile, title = "") %>%
addProviderTiles("CartoDB.PositronNoLabels") %>%
addPolygons(weight = 1, stroke = TRUE, color = "black", fillColor = ~pal5(variable), label = data$variable) %>%
addLegend("bottomright", pal = pal5, values = ~data$variable, title = "") %>%
addProviderTiles("CartoDB.PositronNoLabels") %>%
addPolygons(weight = 1, stroke = TRUE, color = "black", fillColor = ~pal5(data$variable), label = data$variable) %>%
addLegend("bottomright", pal = pal5, values = ~data$variable, title = "") %>%
addLayersControl(overlayGroups = c("", "", "", ""))