Hello!
I'm working on a school project in Shiny. I am about to make a map with cities/teams/stadium locations. I need some help with select input. I have no idea how to make one selectinput dependent on other eg. By selecting "England" in country input, to have only english teams in team input, and other way if I start from selecting a team from all available teams - I would like to have a selection of related country in select input.
Also is it possible to have a popup option based on the selection but showing the capacity?
and how should I add one more chart under the map that shows the capacity of the chosen stadiums from the biggest to the lowest?
How to make the map and the chart "react" to the slider with the capacity?
I would be very glad for any suggestions
Here is my code:
library(dplyr)
library(leaflet)
library(shiny)
shinyApp(
ui = fluidPage(
sliderInput(inputId = "capacity",
label = "Stadium Capacity",
min = 10000, max = 100000, value = 12000, step = 1000),
tags$div(title = "This input has a tool tip",
selectInput(inputId = "country",
label = "Country: ",
choices = sort(unique(data_stadium$Country)))),
tags$div(title = "This input has a tool tip",
selectInput(inputId = "team",
label = "Team: ",
choices = sort(unique(data_stadium$Team)))),
leafletOutput("MapPlot1")
),
server = function(input, output) {
output$MapPlot1 <- renderLeaflet({
leaflet() %>%
addProviderTiles("OpenStreetMap.Mapnik") %>%
setView(lng = 20, lat = 48, zoom = 4)
})
observe({
capacity <- input$capacity
country <- input$country
team <-input$team
sites <- data_stadium %>%
filter(data_stadium$Country %in% country)
leafletProxy("MapPlot1") %>% clearMarkers() %>%
addCircleMarkers(lng = sites$Longitude,
lat = sites$Latitude,
popup = capacity)
})
},
options = list(height = 600)
)