I have a Shiny App that inserts a circle on a map based on the lat lng associated with the zip code input. The map renders when I load it; however, when I attempt to change the value of the zip code via a selectInput object, the map renders a blank window - i.e. the selectedZip variable.
Any help addressing this issue will be appreciated:
library(shiny)
library(leaflet)
# Data
data <- read.csv('VENDOR_PERFORMANCE_EX.csv')
ui <- fluidPage(
titlePanel("VPD"),
sidebarLayout(
sidebarPanel("Inputs"),
mainPanel("Results")),
selectInput("zipInput", "Select Zip Code", data$Zip),
selectInput("vendorInput", "Select Vendor", as.character(data$Vendor)),
leafletOutput("CLEmap", width = "75%", height = 600)
)
server <- function(input, output, session) {
selectedZip <- reactive({
data[data$Zip == input$zipInput, ]
})
output$CLEmap <- renderLeaflet({
leaflet() %>%
addTiles() %>%
setView(-81.730844, 41.430102, zoom = 11) %>%
addCircles(data = selectedZip(), lng = ~ Y, lat = ~ X, radius = 1069)
})
}
shinyApp(ui=ui, server = server)
