Skip to content

addFgb with minZoom != NULL throws error (addFlatGeoBufFiltered) #84

@trafficonese

Description

@trafficonese

This app will throw an error in the console. It happens with the CRAN and dev version.

APP

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)

VM40:1 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'xyArray')
at :1:25169
at x (:1:25380)
at C (:1:28548)
at :16:23137
at async updateResults (:348:24)

If I change minZoom = 2 then the layer will initially be loaded and visible, but as soon as you zoom in, the same error appears.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions