mapbox / mapbox/mapbox-gl-js

QueryRenderedFeatures returning duplicated features

Open
#12,346 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug :lady_beetle:
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
  1. Create geojson source
  2. Attach 2 separate layers that are using single source
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.