Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
trafficonese opened this issue Jun 11, 2024 · 3 comments
Open

Comments

@trafficonese
Copy link
Contributor

trafficonese commented Jun 11, 2024

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.

@tim-salabim
Copy link
Member

I can reproduce this, but I have no clue what's causing this. All I know is that it used to work...

@trafficonese
Copy link
Contributor Author

Ok, this is weird. The xyArray error only comes when the DevTools are opened and the user interacts (zoom/pan) with the map. This happens in Brave, Chrome, Edge.

In Firefox it doesnt work at all and throws another error, although the example from flatgeobuf works in Firefox.

Uncaught (in promise) TypeError: t is null

Maybe this flatgeobuf/flatgeobuf#245 is related?

And I am seeing much more console messages compared to the flatgeobuf example..

@tim-salabim
Copy link
Member

Yeah, it's really strange. In this document from September 2022 everything works as expected, even in firefox (though there are pmtiles related errors when there's no tiles for a zoom level - but that's a different issue)

https://cn-vector-data-vis.s3.eu-central-1.amazonaws.com/cn-vector-data-vis.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants