diff --git a/app/dashboard.Rmd b/app/dashboard.Rmd index 025bea3..5708cab 100644 --- a/app/dashboard.Rmd +++ b/app/dashboard.Rmd @@ -819,8 +819,46 @@ growth_counties <- reactive({ }) output$growth_map <- renderLeaflet({ - leaflet() %>% - addProviderTiles("Stadia.AlidadeSmooth") + req(growth_counties(), input$growth_trend_map_slider, input$growth_map_metric) + + counties_data <- growth_counties() + combined_geom <- st_union(counties_data) + growth_bbox <- st_bbox(combined_geom) + + growth_year <- input$growth_trend_map_slider + growth_county_year <- counties_data %>% + filter(year == growth_year) + + map <- leaflet() %>% + addProviderTiles("Stadia.AlidadeSmooth") %>% + fitBounds( + lng1 = growth_bbox[["xmin"]], + lng2 = growth_bbox[["xmax"]], + lat1 = growth_bbox[["ymin"]], + lat2 = growth_bbox[["ymax"]] + ) + + if (input$growth_map_metric == "Population") { + map <- map %>% + addPolygons( + data = growth_county_year, + fillColor = "red", + color = "red", + fillOpacity = ~population_opacity, + weight = 2 + ) + } else { + map <- map %>% + addPolygons( + data = growth_county_year, + fillColor = "blue", + color = "blue", + fillOpacity = ~housing_opacity, + weight = 2 + ) + } + + map }) observe({ @@ -924,7 +962,6 @@ output$test_dy <- renderDygraph({ #3}) ``` -### County Data {data-height=450 .no-padding} ```{r include=FALSE} # Growth - County Table