leaflet map not rendering with shiny input

My map seems to be re-rendering when I use the select input options however it does not actually update the map with the inputs. My code is below...

library(shiny)
library(leaflet)

ui <- fluidPage(
selectInput(inputId = "select",
label = "Species",
choices = df$Species, multiple = TRUE),
leafletOutput("my_leaf")
)

server <- function(input, output, session){
df <- read.csv("C:\Users\Michael\Documents\TMMC\TMMC_EXCEL_R\PSM5\PatientStabilizationMap.csv", header=TRUE)

## create static element
output$my_leaf <- renderLeaflet({
    
    leaflet() %>%
        addProviderTiles(providers$Esri.NatGeoWorldMap, group = "Nat Geo World")%>%
        addMarkers(data = df, lng= ~Lng, lat= ~Lat,clusterOptions = markerClusterOptions(),
                   popup= ~paste("<h3 style='color: blue'>Stranding Info</h3>","<b>Name:</b>",ï..Name,"<br>","<b>Field ID:</b>",Field.ID,"<br>","<b>Category:</b>",Category, sep=" ")
        )
        
})

## filter data
df_filtered <- reactive({
    df[df$Species >= input$select, ]
})

## respond to the filtered data
observe({
    
    leafletProxy(mapId = "my_leaf", data = df_filtered()) %>%
        clearMarkers() %>%   ## clear previous markers
        clearMarkerClusters()%>%
        addMarkers(data = df, lng= ~Lng, lat= ~Lat,clusterOptions = markerClusterOptions(),
                   popup= ~paste("<h3 style='color: blue'>Stranding Info</h3>","<b>Name:</b>",ï..Name,"<br>","<b>Field ID:</b>",Field.ID,"<br>","<b>Category:</b>",Category, sep=" ")
        )
})

}

shinyApp(ui, server)

Hi, welcome!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this resources, to see how to create one for a shiny app

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.