You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Can someone confirm if that is the case? If so, should we do additional filtering of features based on the viewport bounding box?
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.
this function does not check tiles outside the currently visible viewport
Perhaps we could improve the clarity of documentation about this. querySourceFeatures indeed returns all features inside tiles loaded for the current viewport, and these tiles are often visible only partially — they are rarely aligned to viewport.
To see how this works, set map.showTileBoundaries = true in your code. If you want the features filtered by viewport strictly, you should do the additional filtering on the app side.
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:
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 seenqueryRenderedFeatures
returning features outside of the viewport.Links to related documentation
https://docs.mapbox.com/mapbox-gl-js/api/map/#map#querysourcefeatures
The text was updated successfully, but these errors were encountered: