library(leafem)
library(leaflet)
library(shiny)
library(terra)
library(sf)
## Transform Data to FGB ############
linesdf <- st_as_sf(leaflet::atlStorms2005)
shp <- vect(linesdf)
shp_ext <- unname(as.vector(ext(shp)))
fgb_path <- tempfile(fileext = ".fgb")
writeVector(shp, fgb_path, filetype = "FlatGeobuf")
## UI ##################
ui <- fluidPage(leafletOutput("map", height = 700))
## SERVER ##################
server <- function(input, output){
output$map <- renderLeaflet({
leaflet("map") %>%
fitBounds(shp_ext[1], shp_ext[3], shp_ext[2], shp_ext[4]) %>%
leafem::addMouseCoordinates() %>%
addTiles(group = "Streets") %>%
addFgb(fgb_path,
minZoom = 5,
fill = FALSE
)
})
}
shinyApp(ui = ui, server = server)
This app will throw an error in the console. It happens with the CRAN and dev version.
APP
If I change
minZoom = 2then the layer will initially be loaded and visible, but as soon as you zoom in, the same error appears.