Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

symbolSortKey does not equally sort icon and text #15964

Closed
@johnnewman

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

  1. Draw two features on the map that overlap.
  2. Ensure they both have valid icon and text properties.
  3. Set textOptional to true, iconAllowsOverlap to true, and textAllowsOverlap 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.

TextLayeringProject.zip

Screen Shot 2019-11-22 at 5 25 32 PM

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:

Screen Shot 2019-11-22 at 5 28 10 PM

Configuration

Mapbox SDK versions: 5.4.0
iOS/macOS versions: 13.2.2
Device/simulator models: 11
Xcode version: 11.2.1

Metadata

Assignees

No one assigned

    Labels

    CoreThe cross-platform C++ core, aka mbglbug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions