Calling source.serialize().data after dynamic update with updateData() only returns features from most recent update.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
### mapbox-gl-js version
v3.14.0
### Browser and version
Chrome Version 134.0.6998.45 (Official Build) (arm64)
### Expected behavior
When calling `source.updateData()` to add new features to a geojson source, I expect `map.getSource(sourceId).serialize().data` to include the full data for the source.
For example, if the map loads and a source is added with feature id "1", then later `updateData()` adds features "2" and "3", I expect `map.getSource(sourceId).serialize().data` to show a FeatureCollection with feature Ids "1", "2", and "3".
### Actual behavior
Instead, calling `map.getSource(sourceId).serialize().data` on a source recently updated with `updateData()` returns only the feature that were included in the latest update.
So, when adding features with ids "2" and "3" to a source that already included feature with id "1" using `updateData()`, then calling `map.getSource(sourceId).serialize().data` returns only features "2" and "3".
### Link to the demonstration
https://jsbin.com/sidesih/2/
### Steps to trigger the unexpected behavior
Start with a geojson source with some data and dynamic:true. Add data using updateData. Call `map.getSource().serialize().data` and see that only the data added in updateData is returned.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the behavior in the linked JSBin with a dynamic GeoJSON source, then trace the source's updateData() and serialize() paths in mapbox-gl-js. Verify how the initial data and later updates are represented. Done means serialize().data includes the complete FeatureCollection, including features from both the initial load and subsequent updates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100