querySourceFeatures returns features outside the viewbox
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**: 3.1.2
### Question
We use `querySourceFeatures` to query features in our vector tiles (mvt).
Based on the documentation, we would expect only features within the map viewport to be returned by the method. Relevant part of the docs:
_The domain of the query includes all currently-loaded vector tiles and GeoJSON source tiles: **this function does not check tiles outside the currently visible viewport.**_
What happens though is that the method sometimes returns features that are not within the viewport boundaries.
The only way I could explain that behavior is that it could happen if the we are in a state between 2 zoom levels meaning that the tile doesn't end precisely on the edge of the viewport so that a part of the tile is within the viewport and part is out. And in that case the method returns features within the tile but outside of the viewport.
Questions are:
1. Can someone confirm if that is the case? If so, should we do additional filtering of features based on the viewport bounding box?
2. If so, could that be explained a bit more clear in the docs?
PS.
Another source of confusion is that the description says the method behaves the same as `queryRenderedFeatures` with the difference that it looks for features that might be invisible. But I have never seen `queryRenderedFeatures` returning features outside of the viewport.
### Links to related documentation
https://docs.mapbox.com/mapbox-gl-js/api/map/#map#querysourcefeatures
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 querySourceFeatures API documentation linked in the issue and reproduce the reported behavior using a vector-tile source at fractional zoom. Compare returned features with the viewport and with queryRenderedFeatures. Done means the documented viewport and loaded-tile behavior is unambiguous, including whether additional filtering is expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- api, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100