I create a map using leaflet package in Shiny which have a selectInput
to allow user to select from a site list. The site list also adds into leaflet as markers
You can access the zoom level using input$mapid_zoom
(see here).
In your observe
, you could do:
observe({
sel_site <- df[df$site == input$site,]
isolate({
new_zoom <- 4
if(!is.null(input$map_zoom)) new_zoom <- input$map_zoom
leafletProxy('map') %>%
setView(lng = sel_site$lng, lat = sel_site$lat, zoom = new_zoom)
})
})