Currently, queryRenderedFeatures or querySourceFeatures on a GeoJSON source return geometries that have gone through a round trip to tiled form, reducing coordinate precision and therefore giving different coordinates at different zoom levels. This has proven to be confusing: #5638, #4733, #5397, https://github.com/mapbox/mapbox-gl-native/issues/8992.
For GeoJSON sources specifically, we may be able to change the behavior of queryRenderedFeatures or querySourceFeatures such that features are always returned with their original, input geometry, regardless of zoom level.
I can't _guarantee_ that we'll be able to do this -- there are considerations that we'll need to work through, like whether this means that GeoJSON sources will have different behavior with regards to features being clipped along tile edges, and whether we'd have to give up on #3220. But we should at least investigate it.
For GeoJSON sources specifically, we may be able to change the behavior of
queryRenderedFeaturesorquerySourceFeaturessuch that features are always returned with their original, input geometry, regardless of zoom level.
This change has also been requested on the native side in mapbox/mapbox-gl-native#6178 and mapbox/mapbox-gl-native#7376, where it could help to unblock reimplementing annotations atop GeoJSON sources.
I'm trying to use the coordinate out of the querySourceFeatures to animate a marker, however since the coordinate changes on different zoom levels I run into issues where the coordinate is "invalid" so the marker "disappears".
Is there a temporary alternative to getting the original coordinate?
Is it possible to reverse calculate the coordinate based on tile & zoom level?
Or should I also put the original coordinate as a property in the geojson?
In my case I'm trying to incorporate dynamic behaviour such that when someone selects a feature's Id (elsewhere in the app) I'd like to be able to query the feature (to derive the centroid or bounds) and then fly towards (or fit the bounds) of the selected feature. When zoomed-in and the feature is off-screen, or if only partially (split over adjacent tiles?) then the query returns null or off-centre locations, respectively.
Long story short, it would be really useful to have access to the original features, or at least the original feature centroids or bounds. This saves having to preprocess the geometry elsewhere and storing bounds / centroids.
Most helpful comment
I'm trying to use the coordinate out of the querySourceFeatures to animate a marker, however since the coordinate changes on different zoom levels I run into issues where the coordinate is "invalid" so the marker "disappears".
Is there a temporary alternative to getting the original coordinate?
Is it possible to reverse calculate the coordinate based on tile & zoom level?
Or should I also put the original coordinate as a property in the geojson?