mapbox / mapbox/mapbox-gl-js

`querySourceFeatures` Not Returning All Features Within the Viewport

Open
#13,289 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged needs information :pray:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

I’m encountering an issue where querySourceFeatures is not returning all the features that should be present within the viewport.

Details:

  • Vector Source: In my vector, there are a total of 1,524,444 features.
  • When using querySourceFeatures, I’m only able to retrieve 186,317 features, which is significantly less than expected.
  • I’ve also tried using queryRenderedFeatures, but I am seeing the same result.

Code Snippet:

map.querySourceFeatures('households', {
    sourceLayer: 'households'
});

Steps Taken:

  • I have confirmed that the data source contains the expected number of features.
  • The issue persists with queryRenderedFeatures as well, which makes me believe it’s related to how features are being queried or rendered.

Expected Behavior:
I expect to be able to query all 1,524,444 features within the viewport using querySourceFeatures or queryRenderedFeatures.

Environment:

  • Mapbox version: v3.6.0
  • Browser: Chrome 129.0.6668.58
  • OS: macOS 15

Could anyone please help identify how to retrieve all the features using querySourceFeatures or guide me on what could be causing this limitation? Thanks!

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 by reproducing the provided querySourceFeatures call for the households source layer and compare it with queryRenderedFeatures using the stated viewport and feature counts. Determine whether the difference between 1,524,444 source features and 186,317 queried features is expected or indicates a query problem. Done means documenting the cause or producing a focused fix with a regression test if the behavior is confirmed as a bug.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.