mirror of
https://github.com/dylanbenzi/hurricane_normalization_app.git
synced 2026-07-29 21:01:27 +00:00
add map controls to switch between housing and pop
This commit is contained in:
+32
-27
@@ -842,20 +842,16 @@ growth_counties <- reactive({
|
||||
return(result)
|
||||
})
|
||||
|
||||
output$pop_growth_map <- renderLeaflet({
|
||||
output$growth_map <- renderLeaflet({
|
||||
leaflet() %>%
|
||||
addProviderTiles("Stadia.AlidadeSmooth")
|
||||
})
|
||||
|
||||
output$housing_growth_map <- renderLeaflet({
|
||||
leaflet() %>%
|
||||
addProviderTiles("Stadia.AlidadeSmooth")
|
||||
addProviderTiles("Stadia.AlidadeSmooth")
|
||||
})
|
||||
|
||||
observe({
|
||||
req(
|
||||
growth_counties,
|
||||
input$growth_trend_map_slider
|
||||
input$growth_trend_map_slider,
|
||||
input$growth_map_metric
|
||||
)
|
||||
|
||||
growth_year <- input$growth_trend_map_slider
|
||||
@@ -865,31 +861,40 @@ observe({
|
||||
year == growth_year
|
||||
)
|
||||
|
||||
leafletProxy("pop_growth_map", data = growth_county_year) %>%
|
||||
clearShapes() %>%
|
||||
addPolygons(
|
||||
fillColor = "red",
|
||||
color = "red",
|
||||
fillOpacity = ~population_opacity,
|
||||
weight = 2
|
||||
)
|
||||
|
||||
leafletProxy("housing_growth_map", data = growth_county_year) %>%
|
||||
clearShapes() %>%
|
||||
addPolygons(
|
||||
fillColor = "blue",
|
||||
color = "blue",
|
||||
fillOpacity = ~housing_opacity,
|
||||
weight = 2
|
||||
)
|
||||
if (input$growth_map_metric == "Population") {
|
||||
leafletProxy("growth_map", data = growth_county_year) %>%
|
||||
clearShapes() %>%
|
||||
addPolygons(
|
||||
fillColor = "red",
|
||||
color = "red",
|
||||
fillOpacity = ~population_opacity,
|
||||
weight = 2
|
||||
)
|
||||
} else {
|
||||
leafletProxy("growth_map", data = growth_county_year) %>%
|
||||
clearShapes() %>%
|
||||
addPolygons(
|
||||
fillColor = "blue",
|
||||
color = "blue",
|
||||
fillOpacity = ~housing_opacity,
|
||||
weight = 2
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
leafletOutput("housing_growth_map", height = "100%")
|
||||
leafletOutput("growth_map", height = "100%")
|
||||
```
|
||||
|
||||
### Map Control {data-height=200}
|
||||
```{r}
|
||||
|
||||
radioGroupButtons(
|
||||
"growth_map_metric",
|
||||
label = "Display Metric",
|
||||
choices = c("Population", "Housing"),
|
||||
selected = "Population",
|
||||
status = "outline-primary rounded-0",
|
||||
justified = T
|
||||
)
|
||||
```
|
||||
|
||||
Column {data-width=450}
|
||||
|
||||
Reference in New Issue
Block a user