Skip to content

Unify marker draw order (zIndex, then screen position) - #37

Merged
wf9a5m75 merged 3 commits into
developfrom
fix/marker-zindex-order
Nov 12, 2026
Merged

wf9a5m75 merged 3 commits into
developfrom
fix/marker-zindex-order

Conversation

@wf9a5m75

Copy link
Copy Markdown
Contributor

Summary

Markers stacked differently on every provider: some used raw zIndex, some add order, some -latitude * 1e6 (which put a null-zIndex marker in the southern hemisphere above an explicit zIndex 1). This adds one shared draw-order helper, MarkerDrawOrder, that every provider's marker renderer feeds its native sort key from.

Rule (matches Google Maps JS, measured):

  1. zIndex ?? 0 decides first; larger is in front.
  2. Equal zIndex: the marker lower on screen after rotation is in front (south when north-up). The order is recomputed when the camera heading changes by ≥ 0.5°.
  3. Same screen row: the one further left is in front (west when north-up). Google falls back to add order here; we keep the order independent of add order.

The heading parameter is the native camera heading (clockwise), not MapConductor's bearing, which has the opposite sign. Markers rasterized into tiles stay north-up.

Tests

Unit tests cover heading 0 keeping the previous order, lower-on-screen at 0/90/180/270, zIndex dominating at every heading, and an antimeridian pair.

Provider PRs that use this helper depend on this one.

Commits

  • Add MarkerDrawOrder: one marker stacking rule for every provider
  • Order same-zIndex markers by rotated screen position
  • Name the draw-order frame's heading headingDegrees

Within the marker band a larger zIndex (nil = 0) is in front; at the same
zIndex the more southerly marker is in front, then the more westerly.
key() gives a small Double for engines that sort by floating point
(symbol-sort-key, MKAnnotationView.zPriority); integerKey() packs the
same order into an integer for engines that only take integers
(GMSMarker.zIndex). Driver SPI, so the public API is unchanged.
Google Maps JS puts the marker lower on screen in front and re-sorts
when the map rotates. MarkerDrawOrder now does the same: the tiebreak
is the marker's position in the rotated screen frame (lower first,
then left), from a Frame carrying the camera heading and the longitude
used for antimeridian wrapping. North-up gives the same order as
before. Exact screen-row ties stay left-first instead of Google's add
order, so the order still never depends on add order.

AbstractMarkerController and StrategyMarkerController hand a new Frame
to renderers adopting MarkerDrawOrderFrameReceiver when the heading
moves by 0.5 degrees or more. Tile-rasterised markers keep north-up.
All new API is driver SPI.
Same name as js-sdk-core / android-sdk-core. It is the camera heading
(clockwise, as Google reports), converted from MapConductor's bearing.
@wf9a5m75
wf9a5m75 merged commit 84560b8 into develop Nov 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant