Skip to content

Keep the GPS arrow centered on Android after a ping, cell or repeater view - #37

Merged
MrAlders0n merged 1 commit into
devfrom
claude/android-map-center-after-focus
Oct 18, 2026
Merged

MrAlders0n merged 1 commit into
devfrom
claude/android-map-center-after-focus

Conversation

@MrAlders0n

@MrAlders0n MrAlders0n commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Android users reported that with "center on location" on, the GPS arrow ends up near the very top of the map after the screen layout changes and comes back (for example collapsing and restoring the control panel), instead of sitting in the middle of the map area above the panel.

Cause

Tapping a ping, a coverage cell or a repeater frames the map with CameraUpdate.newLatLngBounds, leaving extra room at the bottom (40% of the screen) for the sheet. MapLibre Android carries that padding into the camera and keeps it as the map's viewport padding. Later camera moves from the plugin never send a padding, so the native core keeps the old one (camera.padding.value_or(state.getEdgeInsets()) in transform.cpp). From then on the map's center sits about 150 px higher than the screen center, and auto-follow adds its own control-panel offset on top of that, so the arrow lands near the top of the screen. The control panel re-center on collapse or restore is what makes it visible when standing still.

iOS is not affected. The fit's padding does reach the map there too, but every later camera move on iOS passes the map's contentInset as its padding (zero, since the app never sets it), so the next move puts the padding back to zero.

Fix

When the last focus view closes (_exitFocusCamera), Android resets the map's viewport padding to zero with updateContentInsets(EdgeInsets.zero). This runs before the zoom back, so the saved pre-focus center also lands at the true center again. It runs behind the same _canAnimateCamera gate as every other camera move, and only on Android.

Testing

  • flutter analyze: no issues
  • flutter test: all 2442 pass
  • Not yet confirmed on an Android phone. To check: turn on center on location, tap a ping or a coverage cell, close it, then collapse and restore the control panel. The arrow should stay in the middle of the map area above the panel. The debug log shows [MAP CENTER] clearing fit padding after focus view when the reset runs.

@MrAlders0n
MrAlders0n merged commit c5bb1df into dev Oct 18, 2026
1 of 2 checks passed
@MrAlders0n
MrAlders0n deleted the claude/android-map-center-after-focus branch October 18, 2026 11:45
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