[google_maps_flutter_web] Options to disable tilt controls and configure gesture handling (#3258)
Transferred from https://github.com/flutter/plugins/pull/4916
tiltControlsEnabled: On web, in satellite view, and at close zoom levels, the map displays tilt controls. This lets you disable them.
gestureHandling: On web, without greedy gesture handling the map can have an overlay saying you can only move the map with two fingers or Cmd+drag. This is not ideal, and greedy gestures lets you make that not happen. I added the other gesture handling options from the [Google Maps documentation](https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions.gestureHandling) for completeness.
*List which issues are fixed by this PR. You must list at least one issue.*
[flutter/flutter/#99044](https://github.com/flutter/flutter/issues/99044)
*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
diff --git a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md
index 6edda3e..86c6f2a 100644
--- a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md
+++ b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 2.4.0
+
+* Adds options for gesture handling and tilt controls on web.
+
## 2.3.1
* Fixes a regression from 2.2.8 that could cause incorrect handling of a
diff --git a/packages/google_maps_flutter/google_maps_flutter/lib/google_maps_flutter.dart b/packages/google_maps_flutter/google_maps_flutter/lib/google_maps_flutter.dart
index 8a1f8ab..8ad5b33 100644
--- a/packages/google_maps_flutter/google_maps_flutter/lib/google_maps_flutter.dart
+++ b/packages/google_maps_flutter/google_maps_flutter/lib/google_maps_flutter.dart
@@ -43,7 +43,8 @@
Tile,
TileOverlayId,
TileOverlay,
- TileProvider;
+ TileProvider,
+ WebGestureHandling;
part 'src/controller.dart';
part 'src/google_map.dart';
diff --git a/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart b/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart
index 08c2286..14fe651 100644
--- a/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart
+++ b/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart
@@ -93,6 +93,7 @@
required this.initialCameraPosition,
this.onMapCreated,
this.gestureRecognizers = const <Factory<OneSequenceGestureRecognizer>>{},
+ this.webGestureHandling,
this.compassEnabled = true,
this.mapToolbarEnabled = true,
this.cameraTargetBounds = CameraTargetBounds.unbounded,
@@ -104,6 +105,7 @@
this.zoomGesturesEnabled = true,
this.liteModeEnabled = false,
this.tiltGesturesEnabled = true,
+ this.fortyFiveDegreeImageryEnabled = false,
this.myLocationEnabled = false,
this.myLocationButtonEnabled = true,
this.layoutDirection,
@@ -179,6 +181,9 @@
/// True if the map view should respond to tilt gestures.
final bool tiltGesturesEnabled;
+ /// True if 45 degree imagery should be enabled. Web only.
+ final bool fortyFiveDegreeImageryEnabled;
+
/// Padding to be set on map. See https://developers.google.com/maps/documentation/android-sdk/map#map_padding for more details.
final EdgeInsets padding;
@@ -282,6 +287,11 @@
/// were not claimed by any other gesture recognizer.
final Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers;
+ /// This setting controls how the API handles gestures on the map. Web only.
+ ///
+ /// See [WebGestureHandling] for more details.
+ final WebGestureHandling? webGestureHandling;
+
/// Creates a [State] for this [GoogleMap].
@override
State createState() => _GoogleMapState();
@@ -518,6 +528,7 @@
MapConfiguration _configurationFromMapWidget(GoogleMap map) {
assert(!map.liteModeEnabled || Platform.isAndroid);
return MapConfiguration(
+ webGestureHandling: map.webGestureHandling,
compassEnabled: map.compassEnabled,
mapToolbarEnabled: map.mapToolbarEnabled,
cameraTargetBounds: map.cameraTargetBounds,
@@ -526,6 +537,7 @@
rotateGesturesEnabled: map.rotateGesturesEnabled,
scrollGesturesEnabled: map.scrollGesturesEnabled,
tiltGesturesEnabled: map.tiltGesturesEnabled,
+ fortyFiveDegreeImageryEnabled: map.fortyFiveDegreeImageryEnabled,
trackCameraPosition: map.onCameraMove != null,
zoomControlsEnabled: map.zoomControlsEnabled,
zoomGesturesEnabled: map.zoomGesturesEnabled,
diff --git a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml
index e56ff51..28928f8 100644
--- a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml
+++ b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml
@@ -2,7 +2,7 @@
description: A Flutter plugin for integrating Google Maps in iOS and Android applications.
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
-version: 2.3.1
+version: 2.4.0
environment:
sdk: ">=3.0.0 <4.0.0"
@@ -23,8 +23,8 @@
sdk: flutter
google_maps_flutter_android: ^2.1.10
google_maps_flutter_ios: ^2.1.10
- google_maps_flutter_platform_interface: ^2.2.1
- google_maps_flutter_web: ^0.5.0
+ google_maps_flutter_platform_interface: ^2.4.0
+ google_maps_flutter_web: ^0.5.2
dev_dependencies:
flutter_test: