From 10e9caaffe5cc716c57be507473ecf96ed7e6358 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Wed, 6 Oct 2021 17:29:27 +0900 Subject: [PATCH] map: keep rotation when changing layer --- lib/widgets/common/map/google/map.dart | 3 ++- lib/widgets/common/map/leaflet/map.dart | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/widgets/common/map/google/map.dart b/lib/widgets/common/map/google/map.dart index 0b844b1d4..aea422c19 100644 --- a/lib/widgets/common/map/google/map.dart +++ b/lib/widgets/common/map/google/map.dart @@ -171,13 +171,14 @@ class _EntryGoogleMapState extends State with WidgetsBindingObse builder: (context, dotEntry, child) { return GoogleMap( initialCameraPosition: CameraPosition( + bearing: -bounds.rotation, target: _toGoogleLatLng(bounds.center), zoom: bounds.zoom, ), onMapCreated: (controller) async { _googleMapController = controller; final zoom = await controller.getZoomLevel(); - await _updateVisibleRegion(zoom: zoom, rotation: 0); + await _updateVisibleRegion(zoom: zoom, rotation: bounds.rotation); setState(() {}); }, // compass disabled to use provider agnostic controls diff --git a/lib/widgets/common/map/leaflet/map.dart b/lib/widgets/common/map/leaflet/map.dart index 7f2b14722..9dbf3aa41 100644 --- a/lib/widgets/common/map/leaflet/map.dart +++ b/lib/widgets/common/map/leaflet/map.dart @@ -151,6 +151,7 @@ class _EntryLeafletMapState extends State with TickerProviderSt options: MapOptions( center: bounds.center, zoom: bounds.zoom, + rotation: bounds.rotation, minZoom: widget.minZoom, maxZoom: widget.maxZoom, // TODO TLAD [map] as of flutter_map v0.14.0, `doubleTapZoom` does not move when zoom is already maximal