TZstatsADS / Fall2021-Project2-group7

Fall2021-Project2-group7 created by GitHub Classroom
1 stars 1 forks source link

Meeting 4 #4

Open jeesunyun opened 3 years ago

jeesunyun commented 3 years ago

Modifications/ Analysis Suggestions

@wanyexin

@MingyuanXia

@jeesunyun

wanyexin commented 3 years ago
observe({
    proxy <- leafletProxy("mymap", data = df)
    palette_testing = c("green", "red")

    color1 <- colorFactor(palette=palette_testing, df$open_now)
    proxy %>% clearControls()

    # clear the map
    leafletProxy("mymap", data = df) %>%
        clearShapes() %>%
        clearMarkers() %>%
        addProviderTiles("CartoDB.Voyager") %>%
        fitBounds(-74.354598, 40.919500, -73.761545, 40.520024)

    # output data related to covid testing sites
    if (input$covid_test){
        leafletProxy("mymap", data = df) %>%
            clearShapes() %>%
            addProviderTiles("CartoDB.Voyager") %>%
            addCircleMarkers(~lon, ~lat, radius=10,
                             color = ~color1(open_now),
                             label = paste(df$formatted_address, ', ', df$name),
                             popup = paste(
                                 "<b>Name:</b>", df$name, "<br>",
                                 "<b>Address:</b>", df$formatted_address, "<br>",
                                 "<b>Rating:</b>", df$rating, "<br>",
                                 "<b>Open now:</b>", df$open_now, "<br>")) %>%
            addLegend("bottomright",
                      pal = color1,
                      values = df$open_now,
                      title = "Status",
                      opacity = 1)
    }

})