GeoJSON source with dynamic: true and cluster: true renders no features
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, typescript
Research direction
Start in GeoJSONWorkerSource.loadData and GeoJSONRT.load, following how features are converted before reaching Supercluster when both dynamic and cluster are enabled. Reproduce the inline example and compare querySourceFeatures results for the three source configurations. Done means dynamic clustered sources render clusters and unclustered points, and updateData re-clusters updated features.
Written by the indexing model from the issue text.
Description
mapbox-gl-js version
3.31.0
Browser and version
Chrome 151, macOS
Expected behavior
A GeoJSON source with both dynamic: true and cluster: true renders clusters and unclustered points, the same as the source without dynamic, and updateData re-clusters the updated features.
Actual behavior
The source renders nothing. querySourceFeatures returns 0 features, whether the data is passed inline to addSource, set with setData, or added with updateData. The same data renders with cluster: true alone, and with dynamic: true alone.
In GeoJSONWorkerSource.loadData, when params.dynamic && params.cluster, the features passed to Supercluster come from this._dynamicIndex.getFeatures(). GeoJSONRT.load stores features after convertFeature, so Supercluster receives features in the internal geojson-vt format instead of GeoJSON Features with geometry.coordinates, and produces an empty index.
Link to the demonstration
Inline repro below.
Steps to trigger the unexpected behavior
const features = Array.from({ length: 1000 }, (_, i) => ({
type: 'Feature',
id: i,
geometry: { type: 'Point', coordinates: [-122.4 + Math.random() * 0.2, 47.55 + Math.random() * 0.2] },
properties: {},
}));
map.on('load', async () => {
const results = {};
for (const [name, options] of Object.entries({
cluster: { cluster: true },
dynamic: { dynamic: true },
dynamicCluster: { dynamic: true, cluster: true },
})) {
map.addSource(name, { type: 'geojson', data: { type: 'FeatureCollection', features }, ...options });
map.addLayer({ id: name, type: 'circle', source: name });
await new Promise((resolve) => map.once('idle', resolve));
results[name] = map.querySourceFeatures(name).length;
}
console.log(results);
});
- Run the snippet on a map centered at zoom 10.
- Observe
clusteranddynamicreport features;dynamicClusterreports 0 and nothing is drawn.
Relevant log output
{ cluster: 42, dynamic: 1061, dynamicCluster: 0 }
No errors are logged.
- Dominant language
- TypeScript
- Stars
- 12.5k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from mapbox/mapbox-gl-js
-
TypeError: Cannot read properties of undefined (reading 'get') when a map is removed while a color-theme LUT is decodingPossibly taken @Piyush495 claimed this 19 days ago. Openauto-triaged bug :lady_beetle:
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
mapbox/mapbox-gl-js#13737 · 1 comment ·
-
auto-triaged bug :lady_beetle:
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
mapbox/mapbox-gl-js#13723 · 2 comments ·
-
auto-triaged bug :lady_beetle:
Difficulty 1/5 Under an hour Newbie friendliness 86/100
mapbox/mapbox-gl-js#13717 ·
-
>= v3.21 Symbol layer without feature-state expression crash the mapPossibly taken @liueric-dev claimed this 60 days ago. Openauto-triaged bug :lady_beetle:
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
mapbox/mapbox-gl-js#13714 · 1 reaction ·
-
auto-triaged feature :green_apple:
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
mapbox/mapbox-gl-js#13676 · 2 comments ·
All issues in mapbox/mapbox-gl-js
Similar issues
-
Native Web
Difficulty 1/5 Under an hour Newbie friendliness 80/100
digitalfabrik/integreat-app#4517 ·
Maintainers usually reply within 2 days
-
TLS guide repeats certs/ in the certificate directoryPossibly taken @maheshrijal claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 92/100
prometheus/docs#3156 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
medusajs/dtc-starter#90 ·
Maintainers usually reply within 1 day
-
usability
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
inmanta/web-console#7632 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
zaidmukaddam/scira#261 ·