Description
When using MGLSymbolStyleLayer's symbolSortKey
expression with textAllowsOverlap
as false, text collisions cause the lower-sort features to take priority. Features with a lower sort will draw their text and cause features of a higher sort to hide theirs.
Steps to reproduce
- Draw two features on the map that overlap.
- Ensure they both have valid
icon
andtext
properties. - Set
textOptional
to true,iconAllowsOverlap
to true, andtextAllowsOverlap
to false.
Expected behavior
When the features collide:
- the text and icon for the higher-sort feature should appear above the lower-sort feature's icon.
- the lower-sort feature's text should be hidden since it collides with the high-sort feature.
Actual behavior
The icons are at the correct z-level, but the lower-sort feature's text has caused the higher-sort feature's text to hide.
The attached zip contains a sample Xcode project that demonstrates this issue. You'll just need to run a pod install and supply an API token in the app delegate. The output of the project is captured in the screenshot below. The red feature has a higher sort value, but its text is hidden.
If I reverse the sort
values by multiplying them all by -1, then the red icon appears with its text, but both the text and the icon are drawn below the now higher blue icon:
Configuration
Mapbox SDK versions: 5.4.0
iOS/macOS versions: 13.2.2
Device/simulator models: 11
Xcode version: 11.2.1