Mapbox-gl-js: Fix bug preventing "queryRenderedFeatures" from returning all features

Created on 1 Jun 2016  Â·  12Comments  Â·  Source: mapbox/mapbox-gl-js

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

  1. Open your browser console
  2. Position the map viewport over Barcelona map marker (so it is only visible)
  3. Zoom in and out over this marker while the marker is still in view
  4. Watch the features that are console.logged/returned by the calling queryRenderedFeatures method

    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

bug

All 12 comments

I can confirm that queryRenderedFeatures is broken in the way you describe in this example.

I had to modify the example slightly to get it to run without crashing my browser. I added {layers: ['markers']} as a parameter to queryRenderedFeatures. http://codepen.io/lucaswoj/pen/oLgqyL

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.

map.zip

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 https://github.com/mapbox/mapbox-gl-native/pull/6773). I'm going to port that into GL JS.

Super cool issue comments. Thanks for that Bruno!
On Tue., 25 Oct. 2016 at 10:37 pm, Bruno de Oliveira Abinader <
[email protected]> wrote:

There is an issue affecting symbol feature queries that we've already
fixed in GL native (see mapbox/mapbox-gl-native#6773
https://github.com/mapbox/mapbox-gl-native/pull/6773). I'm going to
port that into GL JS.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/mapbox/mapbox-gl-js/issues/2647#issuecomment-256010963,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAjVHoc9wNJMbzgB1QGsEvQMbM8H2Xn5ks5q3enigaJpZM4IrPy6
.

Can anyone confirm if #3459 fixes this issue?

It did for me. Thanks a lot @brunoabinader @mourner !

Thank you all - closing for now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

foundryspatial-duncan picture foundryspatial-duncan  Â·  3Comments

muesliq picture muesliq  Â·  3Comments

PBrockmann picture PBrockmann  Â·  3Comments

Scarysize picture Scarysize  Â·  3Comments

rigoneri picture rigoneri  Â·  3Comments