-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
queryRenderedFeatures Does Not Return Hidden Text Symbols #3744
Comments
@x9xjdzz9 the way we've thought about this so far:
It sounds like you want to use querySourceFeatures. |
querySourceFeatures does not allow you to specify a geometry. I need a way to query text based features based on a geometry. |
@x9xjdzz9 if you read the documentation linked above, If by "query text based features based on a geometry" you mean searching within a bounding box, you can also filter the results by whether they lie within the bounding box you desire. |
@peterqliu, I was hoping to use a spatially indexed query. Right now, I'm keeping my points in a separate spatial index with which I perform my queries. But I am assuming MapBox-GL already has the points in a spatial index and uses that for queryRenderedFeatures, and so I feel that my separate index is redundant. How can I filter the results based on a bounding box? I don't see anything about that in the API. All I see are the existential, comparison, and set membership filters in the API. |
@x9xjdzz9 You can use turf.js to do the bounding box filter: http://turfjs.org/docs/#inside or http://turfjs.org/docs/#within . It should work with the geojson objects you get from |
@x9xjdzz9 Another option is to add a second layer to your style referencing the same source that has You might think of queryRenderedFeatures() more as a UI feature than a data-query feature, but it can be coerced into behaving like the latter with a trick like this. |
@x9xjdzz9 That's proposed in #3666 |
I can't figure out what units/projection the feature geometry coordinates are in when I call querySourceFeatures. Using a vector tile source, the feature geometry objects have coordinates like (-154.34, 80.99) for a location near the lat/lon (-77.37, 38.98). |
@x9xjdzz9 The result of |
@x9xjdzz9 note that querySourceFeatures uses the geoJSON specification (specifically, lng-lat order), and returns coordinates in world-wrapped format (i.e. 0 longitude is the same geographic location as 360, 720, etc) |
Added a bug report: #4011 |
When I call queryRenderedFeatures on vector symbols which use text, it will not return any features that are hidden due to overlapping. I would expect it to return all symbols even if they are not visible.
Example: https://jsfiddle.net/x9xjdzz9/jpb8krc3/
The text was updated successfully, but these errors were encountered: