Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PreK-map
mapInput <- eventReactive(input$go,{
newkid<-kid[kid$Borough %in% input$borough &
kid$Type %in% input$type &
kid$Length %in% input$length,]
newkid
})
output$map <- renderLeaflet({
leaflet(kid) %>%
addProviderTiles("CartoDB.Positron") %>%
setView(-73.951801,40.702988, zoom = 11) %>%
addCircleMarkers(~lon, ~lat, radius=~Seats/3, clusterOptions = markerClusterOptions(),
fillColor=~pal(Type),fillOpacity=0.7, stroke=FALSE,
popup=~paste('<b><font color="Green">',Name,'</font></b><br/>','Address:',Address,'<br/>','Seats:',Seats,'<br/>','Tel:',
Phone,'<br/>','Email:',Email,'<br/>','URL: <a target="_blank" href=', Website, ">Offical Website</a>")) %>%
addLegend("bottomright", pal = pal, values = ~kid$Type,
title = "Pre-K Type", opacity = 0.8)
})
observe({
leafletProxy("map", data = mapInput()) %>%
clearMarkerClusters() %>%
addCircleMarkers(~lon, ~lat,radius=~Seats/3, clusterOptions = markerClusterOptions(),
fillColor=~pal(Type),fillOpacity=0.7,stroke=FALSE,
popup=~paste('<b><font color="Green">',Name,'</font></b><br/>','Address:',Address,'<br/>','Seats:',Seats,'<br/>','Tel:',
Phone,'<br/>','Email:',Email,'<br/>','URL: <a target="_blank" href=', Website, ">Offical Website</a>"))})
navbarPage("Pre-K Search in NYC", id='nav',
tabPanel("Pre-K Map",fluidPage(div(class="outer",
leafletOutput("map",width = "100%",height=650),
absolutePanel(h4("Pre-K Finder"),id = "controls", class = "panel", fixed = TRUE,
draggable = TRUE, top =80, left = 130, right = "auto", bottom = "auto",
width = 180, height = "auto",
checkboxGroupInput("borough", h5("Borough:"),
c('Bronx' = "Bronx",'Brooklyn' = "Brooklyn",
'Manhattan' = "Manhattan",'Staten Island' = "Staten Island",
'Queens' = "Queens"),selected=c('Bronx','Brooklyn',
'Manhattan','Staten Island',
'Queens')),
checkboxGroupInput("type", h5("School Type:"),c('Charter'="Charter",
'DOE'="DOE",
'NYCEEC'='NYCEEC'),
selected=c("Charter","DOE","NYCEEC")),
checkboxGroupInput("length", h5("Day Length:"),c("5-Hour" = "5-Hour" ,
"Full Day" = "Full Day",
"Full Day/5-Hour" = "Both Half Day and 5-Hour",
"Full/Half Day"= "Both Full and Half Day",
"Half Day/5-Hour"="Both Half Day and 5-Hour"),
selected=c("5-Hour" ,"Full Day","Both Half Day and 5-Hour",
"Both Full and Half Day", "Both Half Day and 5-Hour")),
actionButton("go", "Click to find"),
helpText("Click on Pre-K Catalog on top for more detailed info")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.