QueryRenderedFeatures returning duplicated features
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: 2.10.0
browser: Google Chrome Version 107.0.5304.62 (Official Build) (x86_64)
Steps to Trigger Behavior
- Create geojson source
- Attach 2 separate layers that are using single source
- Use
queryRenderedFeatures
Link to Demonstration
https://codepen.io/sienki-jenki/pen/rNvOqGy
I have 1 source that is used by 2 layers, when I use map.queryRenderedFeatures(event.point,{layers:["circle-layer"]}) it should return 1 feature since only one feature is rendered on circle-layer. But it actually duplicates feature because(?) circle-label layer is also using same source.
Expected Behavior
Only 1 feature is returned from queryRenderedFeatures
Actual Behavior
2 duplicated features are returned from queryRenderedFeatures
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 with the linked CodePen reproduction and the map.queryRenderedFeatures call using the circle-layer filter. Trace how features from a shared GeoJSON source are collected across the two layers, then verify that the call returns one feature for the circle-layer case without changing the expected behavior for other queries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100