Open thanhnha241199 opened 1 year ago
Also facing this issue on iOS 15.8 (iPhone 6s).
Can you please try explicitly providing a duration to the animateCamera
call?
I experience the same issue, the centering is not the same on iOS and android when using CameraUpdate.newLatLngBounds
.
On iOS, you can use MapLibreMapController.updateContentInsets
before moving the camera to get the same centering than CameraUpdate.newLatLngBounds
with insets on android, but using MapLibreMapController.updateContentInsets
on android gives yet another centering.
So from what I see, only this snippet has a coherent behavior :
/// Center the map on the given [viewPort] taking into account
/// the given [insets].
Future<void> centerOnViewPort(
MaplibreMapController controller, {
required LatLngBounds viewPort,
EdgeInsets? insets,
}) async {
if (defaultTargetPlatform == TargetPlatform.iOS) {
await controller.updateContentInsets(insets ?? EdgeInsets.zero, true);
await controller.animateCamera(CameraUpdate.newLatLngBounds(viewPort));
} else {
await controller.animateCamera(
CameraUpdate.newLatLngBounds(
viewPort,
bottom: insets?.bottom ?? 0,
top: insets?.top ?? 0,
left: insets?.left ?? 0,
right: insets?.right ?? 0,
),
);
}
}
FYI, using CameraUpdate.newCameraPosition
and MapLibreMapController.updateContentInsets
works well on both android and iOS
Can you please try explicitly providing a duration to the
animateCamera
call?
providing a duration doesn't change change the behavior on my side
(but it was quite helpful to debug so thanks for the idea 😅)
This is my code
iOS:
android: