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

updateData throws exception when called on source with dynamic=true and cluster=true #13245

Open
athoma13 opened this issue Aug 1, 2024 · 2 comments
Labels

Comments

@athoma13
Copy link

athoma13 commented Aug 1, 2024

Hi,

I am trying to use updateData on a GeoJSON source that has both dynamic=true and cluster=true.
An exception is throw, and I cannot use updateData.

mapbox-gl-js version: 3.5.2

browser: chrome 127.0.6533.74

Steps to Trigger Behavior

  1. Create a GeoJSON source with dynamic=true AND cluster=true
  2. Once the map is loaded, try adding a feature to the source map using updateData

Link to Demonstration

https://stackblitz.com/edit/mapbox-cluster-and-dynamic-bug?file=main.js

  • See errors in the console when clicking the 'Add Location' button
  • Set cluster=false, and 'Add Location' will add points around (0,0) on the map.

Expected Behavior

I should be allowed to call updateData on a source that has both cluster=true and dynamic=true, or at least an exception that makes sense if setting both flags simultaneously isn't allowed.

Actual Behavior

Exception has occurred: TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
  at $.load (blob:...)
    at blob:...
    at _e.loadGeoJSON (blob:...)
    at _e.loadData (blob:...)
    at av.processTask (blob:...)
    at n2.scheduler.add.t3.metadata.type (blob:...)
    at sv.add (blob:...)
    at av.receive (blob:...)

@athoma13
Copy link
Author

athoma13 commented Aug 8, 2024

Edited for an easier reproduction on stackblitz

@mourner
Copy link
Member

mourner commented Aug 14, 2024

I am trying to use updateData on a GeoJSON source that has both dynamic=true and cluster=true.

Apologies for a confusing error message. The dynamic mode isn't designed to be used together with clustering, since the latter's algorithm requires reclustering the whole dataset on any change, so it can't take advantage of optimizations intended for non-clustering dynamic use cases. We'll add a meaningful error, but as a workaround, please use dynamic: false and setData instead.

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

No branches or pull requests

3 participants