Skip to content

fix(android): apply edge insets to initial camera and watermark reliably - #89

Merged
lodev09 merged 1 commit into
mainfrom
fix/android-edge-insets
Aug 25, 2026
Merged

fix(android): apply edge insets to initial camera and watermark reliably#89
lodev09 merged 1 commit into
mainfrom
fix/android-edge-insets

Conversation

@lodev09

@lodev09 lodev09 commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Problem

Two Android edge-inset bugs, both visible on screens that reserve space for a bottom sheet via edgeInsets:

  1. Initial camera ignores edge insets. onMapReady moved the camera to the initial position before applying padding. Unlike iOS (GMSMapView.padding repositions the camera target into the visible region), Android's setPadding never moves an already-set camera — so the initial camera centered in the full view instead of the inset viewport.

  2. Watermark position is inconsistent. applyWatermarkTranslation assumed setPadding never repositions the watermark (fix(android): reposition Google watermark with edge insets #55) and translated it unconditionally. In practice the renderer sometimes repositions it — depending on renderer version and whether the watermark view existed when padding was set — so the manual translation either double-shifted the logo off-screen or, when the async GoogleWatermark lookup raced and missed, never applied at all.

Fix

  • Apply edge insets before the initial moveCamera in onMapReady; camera updates after setPadding are relative to the padded center.
  • Make the watermark translation measurement-based instead of assumption-based: read the watermark's layout position (excludes translation) relative to the map view and translate only for the remainder — 0 when the renderer already handled it, the full inset when it didn't (including lite/static mode, which never gets setPadding).
  • Re-evaluate via an OnGlobalLayoutListener since the renderer adds and positions the watermark asynchronously; a target cache keyed on the watermark instance makes re-evaluations idempotent and avoids snapping in-flight animated inset changes.

setPadding never repositions an already-set camera, so apply edge
insets before the initial moveCamera in onMapReady.

Whether the renderer repositions the watermark for setPadding varies
by renderer version and timing (and lite mode never applies padding),
so measure the watermark's layout position and translate only for the
remainder, re-evaluating on every layout pass since the renderer adds
and positions it asynchronously.
@lodev09
lodev09 merged commit 684988e into main Aug 25, 2026
3 checks passed
@lodev09
lodev09 deleted the fix/android-edge-insets branch August 25, 2026 17:23
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