From 2d1274372ff6a8e7b1796e6f451ffcc950f29b2f Mon Sep 17 00:00:00 2001 From: Sara <sarasdj@stud.ntnu.no> Date: Tue, 14 May 2024 17:46:48 +0200 Subject: [PATCH] update: minor fix of zoom behavior --- app/lib/widgets/choropleth_map.dart | 2 ++ app/lib/widgets/main_layout.dart | 9 +-------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/app/lib/widgets/choropleth_map.dart b/app/lib/widgets/choropleth_map.dart index b9a4ffbd..2946b7a5 100644 --- a/app/lib/widgets/choropleth_map.dart +++ b/app/lib/widgets/choropleth_map.dart @@ -38,9 +38,11 @@ class ChoroplethMapState extends State<ChoroplethMap> { _initDataSource(); } + /// Resets the map zoom level void resetZoom() { setState(() { _zoomPanBehavior.zoomLevel = 1; + _choroplethMapKey.currentState?.resetZoom(); }); } diff --git a/app/lib/widgets/main_layout.dart b/app/lib/widgets/main_layout.dart index e26e1255..2d451f7c 100644 --- a/app/lib/widgets/main_layout.dart +++ b/app/lib/widgets/main_layout.dart @@ -77,13 +77,6 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { }); } - /// Reset the map zoom and centering - void resetZoom() { - setState(() { - _choroplethMapKey.currentState?.resetZoom(); - }); - } - @override Widget build(BuildContext context) { // Initialise selectedMarker to first element in markerList @@ -248,8 +241,8 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { onTapUp: (_) { setState(() { centerMap = false; + _choroplethMapKey.currentState?.resetZoom(); }); - resetZoom(); // Reset the map zoom }, onTapCancel: () { setState(() { -- GitLab