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

Wait for camera initialization before carrying out queryRegion #120

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

katamartin
Copy link
Member

This PR sets up a this.cameraInitialized promise to track whether the camera values have been set for the first time, and then waits for that promise to resolve before carrying out any tile querying in this.queryRegion(). This prevents the following error from being thrown because of bad key computation due to empty this.zoom, which could occur when a Raster was initialized with an open region picker.

TypeError: Cannot read properties of undefined (reading 'hasLoadedChunks')
  • Avoids potential NaN value for this.level
  • And subsequently, avoids computing chunk keys in getTilesOfRegion() that contain NaNs
    • This would trigger above error when checking !this.tiles[key].hasLoadedChunks(chunks) with a non-existent key

- Ensures that zoom will be present
- Avoids potential NaN value for level and subsequently, chunk keys
@katamartin katamartin requested a review from Shane98c June 17, 2024 13:18
Copy link

vercel bot commented Jun 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
maps-demo ⬜️ Ignored (Inspect) Jun 17, 2024 1:18pm
maps-docs ⬜️ Ignored (Inspect) Jun 17, 2024 1:18pm

Copy link
Member

@Shane98c Shane98c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for tracking this one down!!

@katamartin katamartin merged commit d650aeb into main Jun 17, 2024
10 checks passed
@katamartin katamartin deleted the katamartin/camera-initialization branch June 17, 2024 13:54
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

Successfully merging this pull request may close these issues.

2 participants