这是我尝试过的
server <- function(input, output) {
observe({
output$mymap <- renderLeaflet({
leaflet() %>%
addTiles() %>%
fitBounds(-124.7666, 49.4000, -67.0583, 25.0666)%>%
setView(-95.91245, 37.2333, zoom = 3)
})
click = input$mymap_click
if(is.null(click))
return()
leafletProxy('mymap')%>%addMarkers(lng = click$lng,
lat = click$lat)%>%
setView(lng = click$lng,
lat = click$lat, zoom =7)
output$text <- renderText(paste(click$lng,click$lat))
})
}
ui <- fluidPage(textOutput("text"),
leafletOutput("mymap"))
shinyApp(ui = ui, server = server)
但我想要的不是反应性输出文本,而是动态的,即地图应该随着纬度、经度值的变化而变化,反之亦然