mirror of
https://github.com/dylanbenzi/hurricane_normalization_app.git
synced 2026-07-30 05:08:57 +00:00
add map controls to switch between housing and pop
This commit is contained in:
+31
-26
@@ -842,12 +842,7 @@ growth_counties <- reactive({
|
|||||||
return(result)
|
return(result)
|
||||||
})
|
})
|
||||||
|
|
||||||
output$pop_growth_map <- renderLeaflet({
|
output$growth_map <- renderLeaflet({
|
||||||
leaflet() %>%
|
|
||||||
addProviderTiles("Stadia.AlidadeSmooth")
|
|
||||||
})
|
|
||||||
|
|
||||||
output$housing_growth_map <- renderLeaflet({
|
|
||||||
leaflet() %>%
|
leaflet() %>%
|
||||||
addProviderTiles("Stadia.AlidadeSmooth")
|
addProviderTiles("Stadia.AlidadeSmooth")
|
||||||
})
|
})
|
||||||
@@ -855,7 +850,8 @@ output$housing_growth_map <- renderLeaflet({
|
|||||||
observe({
|
observe({
|
||||||
req(
|
req(
|
||||||
growth_counties,
|
growth_counties,
|
||||||
input$growth_trend_map_slider
|
input$growth_trend_map_slider,
|
||||||
|
input$growth_map_metric
|
||||||
)
|
)
|
||||||
|
|
||||||
growth_year <- input$growth_trend_map_slider
|
growth_year <- input$growth_trend_map_slider
|
||||||
@@ -865,31 +861,40 @@ observe({
|
|||||||
year == growth_year
|
year == growth_year
|
||||||
)
|
)
|
||||||
|
|
||||||
leafletProxy("pop_growth_map", data = growth_county_year) %>%
|
if (input$growth_map_metric == "Population") {
|
||||||
clearShapes() %>%
|
leafletProxy("growth_map", data = growth_county_year) %>%
|
||||||
addPolygons(
|
clearShapes() %>%
|
||||||
fillColor = "red",
|
addPolygons(
|
||||||
color = "red",
|
fillColor = "red",
|
||||||
fillOpacity = ~population_opacity,
|
color = "red",
|
||||||
weight = 2
|
fillOpacity = ~population_opacity,
|
||||||
)
|
weight = 2
|
||||||
|
)
|
||||||
leafletProxy("housing_growth_map", data = growth_county_year) %>%
|
} else {
|
||||||
clearShapes() %>%
|
leafletProxy("growth_map", data = growth_county_year) %>%
|
||||||
addPolygons(
|
clearShapes() %>%
|
||||||
fillColor = "blue",
|
addPolygons(
|
||||||
color = "blue",
|
fillColor = "blue",
|
||||||
fillOpacity = ~housing_opacity,
|
color = "blue",
|
||||||
weight = 2
|
fillOpacity = ~housing_opacity,
|
||||||
)
|
weight = 2
|
||||||
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
leafletOutput("housing_growth_map", height = "100%")
|
leafletOutput("growth_map", height = "100%")
|
||||||
```
|
```
|
||||||
|
|
||||||
### Map Control {data-height=200}
|
### Map Control {data-height=200}
|
||||||
```{r}
|
```{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}
|
Column {data-width=450}
|
||||||
|
|||||||
Reference in New Issue
Block a user