-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Fix bug preventing "queryRenderedFeatures" from returning all features #2647
Comments
I can confirm that I had to modify the example slightly to get it to run without crashing my browser. I added |
I'm also affected by this bug. I took the "Highlight features within a bounding box" example, and changed it to show the bug. I find that it only happens with symbol layers and only when you change from the initial zoom level. So, with the attached program, hold down shift to drag a rectangle and you will see that only some of the points are selected (they are colored red when selected). But it only happens after you have zoomed in or out. |
The idea here is that if the current bounds are contained within the previous bounds, mapbox-gl-js still contains the data and will display it without another server roundtrip. The insight that springs from this is that there are two event handlers that need to be given to the map component: onBoundsChange: called every time the bounds change. This would be used to update the url. onMissingData: called when the current map bounds are outside of previous bounds. We then have area within the map bounds for which we need data. These two callbacks seem to form the basis of a saner API for the map component. TODO: Currently we recalculate the summary, after loading data for the current bounds. If we are now longer hitting the server for each change of bounds, we now need to ask the map which elements of data are currently visible and recalculate the summary based on that. The function that does that is `queryRenderedFeatures`: `map.queryRenderedFeatures(map.getBounds().toArray(), {layers: [ "markers" , "selected" ]})` The problem here is that it returns nothing, duplicates or the right thing seemingly at random. issue: mapbox/mapbox-gl-js#2647 When that issue is resolved, revisit this.
We are affected as well here. Is there a workaround we can use until this is solved ? |
I initially thought that the issue was solved by #2988, but after upgrading I can confirm that the issue still exists. |
This may require a different issue, but if I zoom out and features are hidden behind each other, or another layer is on top of the features from the layer I'm selecting from, the hidden features are not selected. |
I ran into this bug too. From what I understand, I traced it to this tilesIn method behaving weirdly on non-integer zoom levels. This bug appears here: when points are in the right-most or bottom-most tiles, they do not get queried at intermediary zoom levels. |
Possibly related to mapbox/mapbox-gl-native#6055. |
There is an issue affecting symbol feature queries that we've already fixed in GL native (see mapbox/mapbox-gl-native#6773). I'm going to port that into GL JS. |
Super cool issue comments. Thanks for that Bruno!
|
Can anyone confirm if #3459 fixes this issue? |
It did for me. Thanks a lot @brunoabinader @mourner ! |
Thank you all - closing for now. |
Hi Guys,
Love your work.
I think that we may have a bug to contribute. Something that is unexpected and unpredictable behaviour around the queryRenderedFeatures API call on map. We observe occasions where the map markers are returned, and then other occasions that they are not - despite them still being rendered and no changes to layers/sources - just moving/zooming the map.
Please see the following code pen showing the issue;
http://codepen.io/cammanderson/pen/bc7ceb108e340cb30fa524ff982e761d?editors=1010
mapbox-gl-js version: 0.19.0
Steps to Trigger Behavior
Expected Behavior
The console should always show the map marker for Barcelona while you zoom in and zoom out. queryRenderedFeatures should always return the markers that are rendered on screen.
Actual Behavior
There are occasions where the marker will not be returned while zooming in and out. It is like at some stages the marker is no longer present, even though it is rendered on screen at that time.
This can sometimes happen on dragging the map around, like it shows up in the top-right quadrant of the screen, but then disappears from being returned when on the bottom right. This seems to change as you move around the map.
Let me know if my example has errors, if so, it's been a long day sorry. But I observed this on our application, then was able to reproduce this using codepen (just trying to make sure it wasn't just our code implementation in our app).
Thanks guys,
Cheers
Cam
The text was updated successfully, but these errors were encountered: