refactor: improve filtering logic and map initialization

Co-authored-by: aider (deepseek/deepseek-chat) <aider@aider.chat>
This commit is contained in:
2026-03-13 06:31:38 -04:00
parent 1b75760496
commit 6a11f96f33

28
app.R
View File

@@ -362,9 +362,8 @@ server <- function(input, output, session) {
# Initialize filteredOwners with all owners # Initialize filteredOwners with all owners
filteredOwners <- reactiveVal(owners) filteredOwners <- reactiveVal(owners)
# Update filtered owners when filter button is clicked # Function to filter owners based on inputs
observeEvent(input$filterButton, { filterOwners <- function() {
# Start with all owners
filtered <- owners filtered <- owners
# Filter by subdivision if specified # Filter by subdivision if specified
@@ -392,13 +391,28 @@ server <- function(input, output, session) {
filter(grepl(input$location, location, ignore.case = TRUE)) filter(grepl(input$location, location, ignore.case = TRUE))
} }
filteredOwners(filtered) return(filtered)
}
# Update filtered owners when filter button is clicked
observeEvent(input$filterButton, {
filteredOwners(filterOwners())
}) })
# Also update when the app starts # Also update when any of the filter inputs change
observe({ observe({
# Trigger initial update # Track dependencies
filteredOwners(owners) input$name
input$location
input$sub_name
# Update filtered owners, but only if the filter button has been clicked at least once
# To prevent immediate filtering on app start
if (!is.null(input$filterButton)) {
if (input$filterButton > 0) {
filteredOwners(filterOwners())
}
}
}) })
mean_lat <- reactive({ mean_lat <- reactive({