Skip to content

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

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 ordering rule for every driver
  • Check that the default icon anchor stays on the pin tip at any size
  • Order same-zIndex markers by screen position

Within the marker band, zIndex (null = 0) is the primary key and a
south-then-west tiebreak in [0, 0.5) breaks ties, so the key never
crosses an explicit zIndex. It replaces calculateZIndex for markers,
whose -latitude * 10^6 value made Google Maps draw an explicit zIndex 1
behind an unspecified marker (north) and let unspecified markers beat
explicit ones in the southern hemisphere.

Marker tiles now draw in the same order instead of the spatial index
enumeration order.
Measured on device: the tip-to-anchor gap is the same proportion of the
bitmap with scale 0.6, scale 2, iconSize 28dp and the default, so scale
does not shift the anchor.
MarkerDrawOrder now takes the camera heading (and the center longitude for
the antimeridian). With equal zIndex the marker lower on screen is in
front and, on the same row, the one further left, matching Google Maps
JS. At heading 0 the order is unchanged (south, then west).

BaseMapViewController tracks the heading and, once rotation settles,
asks every marker controller to reorder through
MarkerOverlayRendererInterface.onDrawOrderFrameChanged. Compose-drawn
markers use rememberMarkerDrawOrderFrame. Markers drawn into tiles stay
north-up.
@wf9a5m75
wf9a5m75 merged commit b8d598a 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