map: keep rotation when changing layer

This commit is contained in:
Thibault Deckers 2021-10-06 17:29:27 +09:00
parent 51c92fe6ed
commit 10e9caaffe
2 changed files with 3 additions and 1 deletions

View file

@ -171,13 +171,14 @@ class _EntryGoogleMapState extends State<EntryGoogleMap> with WidgetsBindingObse
builder: (context, dotEntry, child) { builder: (context, dotEntry, child) {
return GoogleMap( return GoogleMap(
initialCameraPosition: CameraPosition( initialCameraPosition: CameraPosition(
bearing: -bounds.rotation,
target: _toGoogleLatLng(bounds.center), target: _toGoogleLatLng(bounds.center),
zoom: bounds.zoom, zoom: bounds.zoom,
), ),
onMapCreated: (controller) async { onMapCreated: (controller) async {
_googleMapController = controller; _googleMapController = controller;
final zoom = await controller.getZoomLevel(); final zoom = await controller.getZoomLevel();
await _updateVisibleRegion(zoom: zoom, rotation: 0); await _updateVisibleRegion(zoom: zoom, rotation: bounds.rotation);
setState(() {}); setState(() {});
}, },
// compass disabled to use provider agnostic controls // compass disabled to use provider agnostic controls

View file

@ -151,6 +151,7 @@ class _EntryLeafletMapState extends State<EntryLeafletMap> with TickerProviderSt
options: MapOptions( options: MapOptions(
center: bounds.center, center: bounds.center,
zoom: bounds.zoom, zoom: bounds.zoom,
rotation: bounds.rotation,
minZoom: widget.minZoom, minZoom: widget.minZoom,
maxZoom: widget.maxZoom, maxZoom: widget.maxZoom,
// TODO TLAD [map] as of flutter_map v0.14.0, `doubleTapZoom` does not move when zoom is already maximal // TODO TLAD [map] as of flutter_map v0.14.0, `doubleTapZoom` does not move when zoom is already maximal