231 lines
6.1 KiB
R
231 lines
6.1 KiB
R
# load libraries ----
|
|
library(shiny)
|
|
library(shinyMobile)
|
|
library(leaflet)
|
|
library(sf)
|
|
library(dplyr)
|
|
library(leafpop)
|
|
library(DT)
|
|
|
|
# load data ----
|
|
owners <- readRDS("./data/owners.rds")
|
|
sbdvn <- sf::st_read("./data/plats/plats.shp")
|
|
|
|
# define ui
|
|
ui <- f7Page(
|
|
title = "St. Andrews",
|
|
tags$head(
|
|
tags$link(rel = "manifest", href = "manifest.json"),
|
|
tags$link(rel = "apple-touch-icon", sizes = "180x180", href = "images/apple-touch-icon.png"),
|
|
tags$meta(name = "apple-mobile-web-app-capable", content = "yes"),
|
|
tags$meta(name = "apple-mobile-web-app-status-bar-style", content = "default"),
|
|
tags$style(HTML("
|
|
.dataTables_wrapper {
|
|
color: white;
|
|
}
|
|
.dataTables_wrapper table.dataTable thead th,
|
|
.dataTables_wrapper table.dataTable tbody td {
|
|
color: white;
|
|
}
|
|
.dataTables_wrapper table.dataTable tbody tr.odd {
|
|
background-color: #333;
|
|
}
|
|
.dataTables_wrapper table.dataTable tbody tr.even {
|
|
background-color: #444;
|
|
}
|
|
.dataTables_wrapper .dataTables_paginate .paginate_button {
|
|
color: white !important;
|
|
}
|
|
.dataTables_wrapper .dataTables_paginate .paginate_button.current{
|
|
color: black !important;
|
|
}
|
|
.dataTables_filter {
|
|
display: none; /* Hide the search box */
|
|
}
|
|
"))
|
|
),
|
|
options = list(
|
|
theme = "ios",
|
|
dark = TRUE,
|
|
pullToRefresh = TRUE
|
|
),
|
|
f7SingleLayout(
|
|
navbar = f7Navbar(title = "St. Andrews Park"),
|
|
toolbar = f7Toolbar(
|
|
position = "bottom",
|
|
f7Link(label = "SC-PA", href = "https://www.sc-pa.com/home/"),
|
|
f7Link(label = "GIS", href = "https://data-sarco.opendata.arcgis.com/")
|
|
),
|
|
f7Card(
|
|
title = "About",
|
|
divider = "TRUE",
|
|
img(src = "st_andrews.jpg", width = "100%"),
|
|
"St. Andrews Park is located in Venice, Florida. The condominiums are a mix of single-family homes, villas (2 and 4 units) and multi-unit buildings (8 units). There are 388 separate properties within 14 subdivisions. St. Andrews Park is one of many communities in the Plantation Golf and Country Club. It is should not be confused with the adjacent community St. Andrews East.",
|
|
footer = tagList(
|
|
f7Link("More Info", href = "http://www.cpmi.us/standrews-plantation/outside_home.asp")
|
|
)
|
|
),
|
|
f7Card(
|
|
title = "Owners:",
|
|
divider = TRUE,
|
|
raised = TRUE,
|
|
f7List(
|
|
inset = TRUE,
|
|
dividers = TRUE,
|
|
strong = TRUE,
|
|
outline = FALSE,
|
|
f7Text(
|
|
inputId = "name",
|
|
label = "Last Name:",
|
|
placeholder = "\"Patel\""
|
|
),
|
|
f7Text(
|
|
inputId = "location",
|
|
label = "Address:",
|
|
placeholder = "\"123 Chalmers\""
|
|
),
|
|
f7Select(
|
|
inputId = "sub_name",
|
|
label = "Select Subdivision:",
|
|
choices = c("All", sort(sbdvn$sub_name))
|
|
),
|
|
tags$br(),
|
|
f7Button(
|
|
inputId = "filterButton",
|
|
label = "Find Owners",
|
|
icon = "",
|
|
color = "blue"
|
|
)
|
|
)
|
|
),
|
|
f7Card(
|
|
title = "Map:",
|
|
divider = TRUE,
|
|
leafletOutput("map")
|
|
),
|
|
f7Card(
|
|
title = "Table:",
|
|
divider = TRUE,
|
|
DTOutput("table")
|
|
)
|
|
)
|
|
)
|
|
|
|
|
|
# define server ----
|
|
server <- function(input, output) {
|
|
|
|
filteredSbdvn <- reactive({
|
|
if (is.null(input$sub_name) || input$sub_name == "All") {
|
|
return(sbdvn$max_sub_id)
|
|
} else {
|
|
return(
|
|
sbdvn %>%
|
|
filter(sub_name == input$sub_name) %>%
|
|
pull(max_sub_id)
|
|
)
|
|
}
|
|
})
|
|
|
|
filteredOwners <- reactiveVal(owners)
|
|
|
|
observeEvent(input$filterButton, {
|
|
filtered_owners <-
|
|
owners %>%
|
|
filter(subdivision %in% filteredSbdvn()) %>%
|
|
filter(
|
|
grepl(input$name, owner_1, ignore.case = TRUE) |
|
|
grepl(input$name, owner_2, ignore.case = TRUE)
|
|
) %>%
|
|
filter(grepl(input$location, location, ignore.case = TRUE))
|
|
|
|
filteredOwners(filtered_owners)
|
|
})
|
|
|
|
mean_lat <- reactive({
|
|
filteredOwners() %>%
|
|
st_coordinates() %>%
|
|
.[, "Y"] %>%
|
|
mean()
|
|
})
|
|
|
|
mean_lng <- reactive({
|
|
filteredOwners() %>%
|
|
st_coordinates() %>%
|
|
.[, "X"] %>%
|
|
mean()
|
|
})
|
|
|
|
|
|
output$map <- renderLeaflet({
|
|
if (!is.null(filteredOwners()) && nrow(filteredOwners()) > 0) {
|
|
leaflet() %>%
|
|
addProviderTiles("CartoDB.Voyager") %>%
|
|
addPolygons(
|
|
data = sbdvn,
|
|
color = "red",
|
|
weight = 2,
|
|
opacity = 0.5,
|
|
fillOpacity = 0.2,
|
|
label = ~sub_name,
|
|
group = "Subdivisions"
|
|
) %>%
|
|
addMarkers(
|
|
data = filteredOwners(),
|
|
#color = ~ifelse(homestead == 1, "green", "red"),
|
|
popup = popupTable(
|
|
filteredOwners(),
|
|
row.numbers = FALSE,
|
|
feature.id = FALSE,
|
|
zcol = c(
|
|
"label",
|
|
"owner_1",
|
|
"owner_2"
|
|
)
|
|
),
|
|
group = "Owners"
|
|
) %>%
|
|
addLayersControl(
|
|
overlayGroups = c("Subdivisions", "Owners"),
|
|
options = layersControlOptions(collapsed = FALSE)
|
|
) %>%
|
|
setView(lng = mean_lng(), lat = mean_lat(), zoom = 16)
|
|
} else {
|
|
leaflet() %>%
|
|
addProviderTiles("CartoDB.Voyager") %>%
|
|
addPolygons(
|
|
data = sbdvn,
|
|
color = "red",
|
|
weight = 2,
|
|
opacity = 0.5,
|
|
fillOpacity = 0.2,
|
|
label = ~sub_name,
|
|
group = "Subdivisions"
|
|
) %>%
|
|
setView(lng = -82.362253, lat = 27.076199, zoom = 16)
|
|
}
|
|
|
|
|
|
})
|
|
|
|
output$table <- renderDT({
|
|
my_table <-
|
|
filteredOwners() %>%
|
|
st_drop_geometry() %>%
|
|
select(label, owner_1, owner_2, homestead)
|
|
datatable(my_table,
|
|
colnames = c("Address", "Owner 1", "Owner 2", "Homestead"),
|
|
rownames = FALSE,
|
|
options = list(
|
|
pageLength = 10,
|
|
scrollX = TRUE,
|
|
searching = FALSE,
|
|
lengthMenu = c(5, 10, 25, 50),
|
|
dom = 'tpi'
|
|
)
|
|
)
|
|
})
|
|
}
|
|
|
|
# Run the app
|
|
shinyApp(ui, server) |