mapbox / mapbox-gl-js

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL
https://docs.mapbox.com/mapbox-gl-js/
Other
11.07k stars 2.21k forks source link

symbol-sort-key doesnt influence feature order of queryRenderedFeatures #10800

Open enersis-pst opened 3 years ago

enersis-pst commented 3 years ago

If symbol-sort-key is used the markers are visuell sorted by a property. But by click on the higher marker the lower will be first in the list of queryRenderedFeatures.

mapbox-gl-js version: 2.3.1

browser: Chrome

Steps to Trigger Behavior

  1. open example
  2. zoom out until markers overlaps each others
  3. click on a marker

Link to Demonstration

https://jsfiddle.net/7t02vbhc/63/

Expected Behavior

console should output A

Actual Behavior

console output B

rreusser commented 3 years ago

Thanks for the report, @enersis-pst, and thanks very much for the demonstration! Just to add some context, the queryRenderedFeatures docs say:

The topmost rendered feature appears first in the returned array, and subsequent features are sorted by descending z-order.

so that this does sound like a bug to me (or at the very least something which requires clear explanation in the docs if, for some technical reason, this behavior is currently expected/necessary).