I am creating a map using a booklet package in Shiny that has selectInput so that the user can select from a list of sites. A list of sites is also added to the flyer as markers.
When a user selects a new site, I want to map the map to the selected site without changing the zoom level. The setView function can be called to set the center points, but should indicate the level of zoom.
Is it possible to get the zoom level of the flyer map that can be used in the setView function?
This is a minimal example for playing with my question with reset zoom level.
library(shiny) library(leaflet) df <- data.frame( site = c('S1', 'S2'), lng = c(140, 120), lat = c(-20, -30), stringsAsFactors = FALSE)
PS: when you play with these codes, adjust the zoom level before choosing a new site.
Thanks for any suggestions.
r shiny leaflet
Bangyou
source share