Repository navigation
Keep the GPS arrow centered on Android after a ping, cell or repeater view - #37
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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())intransform.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
contentInsetas 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 withupdateContentInsets(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_canAnimateCameragate as every other camera move, and only on Android.Testing
flutter analyze: no issuesflutter test: all 2442 pass[MAP CENTER] clearing fit padding after focus viewwhen the reset runs.