Skip to content

fix(android): keep markers when zIndex reorders them - #111

Merged
lodev09 merged 2 commits into
mainfrom
fix/android-marker-reorder
Nov 10, 2026
Merged

lodev09 merged 2 commits into
mainfrom
fix/android-marker-reorder

Conversation

@lodev09

@lodev09 lodev09 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Summary

On Android, custom-view markers moved by Reanimated disappeared, and then flickered, whenever their zIndex changed their draw order.

Fabric moves a reordered child by removing it from the map view and inserting it again. The removal took the Google marker off the map:

  • Disappearing: the insert did nothing. A custom-view marker is only added after its first layout, and an already laid-out view gets no new layout. So the marker never came back.
  • Flicker: after re-adding it, every reorder still deleted the Google marker and created a new one with a new icon bitmap.

The example's Reanimated fleet shows both, because each truck's zIndex follows its latitude. Path motion doesn't change zIndex, so it was not affected.

Fixes:

  • LuggMapView waits one loop before it removes a child's map object. If Fabric inserts the same view again first, the removal is cancelled, and the marker, its icon and its position are not touched. This also covers polylines, polygons, circles and the other overlays. Children that are really removed are still removed on the next loop.
  • syncMarkerView adds a marker back when a custom view that has already been laid out is inserted again in a later batch. Custom views still wait for their first layout.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Test Plan

Android emulator (Pixel 10 Pro XL), Release build of the bare example: Motion: Reanimated, Fleet (10) and Fleet (50).

  • Before: within about 10 s, every fleet truck disappears. Logging showed removeMarkerView calls for markers that were still mounted, with no add after them.
  • With the first fix: the trucks stay, but they flicker on every reorder.
  • With both fixes: all trucks stay and don't flicker. Logging showed that each Google marker was created once at startup and never again during 40 s of motion with 50 trucks.

Screenshots / Videos

Checklist

  • I tested on iOS
  • I tested on Android
  • I tested on Web
  • I updated the documentation (if needed)

@vercel

vercel Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lugg-maps Ready Ready Preview Nov 10, 2026 8:13pm UTC

Request Review

@lodev09 lodev09 changed the title fix(android): re-add custom markers moved by zIndex changes fix(android): keep markers when zIndex reorders them Nov 10, 2026
@lodev09
lodev09 merged commit 06c6457 into main Nov 10, 2026
5 checks passed
@lodev09
lodev09 deleted the fix/android-marker-reorder branch November 10, 2026 20:14
@lodev09 lodev09 mentioned this pull request Nov 10, 2026
1 of 8 tasks

This branch was successfully deployed

1 active deployment
Preview — f51c51c0 Deployed Nov 10, 2026 by vercel[bot]
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