R传单加载 - 数据缩放界限

时间:2017-07-07 15:45:01

标签: r shiny leaflet sf

我有一个闪亮的应用程序,有大量的行

我想仅在缩放15处查看它并仅加载可见部分

library(leaflet)
library(shiny)
library(dplyr)
library(sf)

#random multilinestring
polyline_test <-st_multilinestring()


ui <- fluidPage(
  leafletOutput("map")
)

 server <- function(input, output, session){

 output$map <- renderLeaflet({
   leaflet() %>% 
     addTiles() 
})

 ##Only select data visible on the map

new_zoom <- reactive({
    if(!is.null(input$map_zoom)){
     new_zoom <- input$map_zoom
   }
     else {new_zoom <- 2}
 })

polyline_visible <- reactive({
   validate(
      need(new_zoom()>15,"t")
 )
#bbox_zone <- input$map_bounds
#st_polygon()
#polyline_test 
#What is the best way to extract the lines within the bounds ?

})

 #Show layer only at zoom 15

  observe({
      if (new_zoom() > 15) {
         leafletProxy("map") %>%
         addPolylines(data = polyline_visible())
      }else{
         leafletProxy("map") %>% clearShapes()
      }
})
}

shinyApp(ui = ui, server = server)

我想知道在可见地图范围内提取线条的最佳方法吗?

0 个答案:

没有答案