Skip to content

Commit 18d5506

Browse files
authored
[google_maps_flutter_web] Options to disable tilt controls and configure gesture handling (#3258)
Transferred from flutter/plugins#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](flutter/flutter#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].*
1 parent 8028caf commit 18d5506

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.4.0
2+
3+
* Adds options for gesture handling and tilt controls on web.
4+
15
## 2.3.1
26

37
* Fixes a regression from 2.2.8 that could cause incorrect handling of a

packages/google_maps_flutter/google_maps_flutter/lib/google_maps_flutter.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ export 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf
4343
Tile,
4444
TileOverlayId,
4545
TileOverlay,
46-
TileProvider;
46+
TileProvider,
47+
WebGestureHandling;
4748

4849
part 'src/controller.dart';
4950
part 'src/google_map.dart';

packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class GoogleMap extends StatefulWidget {
9393
required this.initialCameraPosition,
9494
this.onMapCreated,
9595
this.gestureRecognizers = const <Factory<OneSequenceGestureRecognizer>>{},
96+
this.webGestureHandling,
9697
this.compassEnabled = true,
9798
this.mapToolbarEnabled = true,
9899
this.cameraTargetBounds = CameraTargetBounds.unbounded,
@@ -104,6 +105,7 @@ class GoogleMap extends StatefulWidget {
104105
this.zoomGesturesEnabled = true,
105106
this.liteModeEnabled = false,
106107
this.tiltGesturesEnabled = true,
108+
this.fortyFiveDegreeImageryEnabled = false,
107109
this.myLocationEnabled = false,
108110
this.myLocationButtonEnabled = true,
109111
this.layoutDirection,
@@ -179,6 +181,9 @@ class GoogleMap extends StatefulWidget {
179181
/// True if the map view should respond to tilt gestures.
180182
final bool tiltGesturesEnabled;
181183

184+
/// True if 45 degree imagery should be enabled. Web only.
185+
final bool fortyFiveDegreeImageryEnabled;
186+
182187
/// Padding to be set on map. See https://developers.google.com/maps/documentation/android-sdk/map#map_padding for more details.
183188
final EdgeInsets padding;
184189

@@ -282,6 +287,11 @@ class GoogleMap extends StatefulWidget {
282287
/// were not claimed by any other gesture recognizer.
283288
final Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers;
284289

290+
/// This setting controls how the API handles gestures on the map. Web only.
291+
///
292+
/// See [WebGestureHandling] for more details.
293+
final WebGestureHandling? webGestureHandling;
294+
285295
/// Creates a [State] for this [GoogleMap].
286296
@override
287297
State createState() => _GoogleMapState();
@@ -518,6 +528,7 @@ class _GoogleMapState extends State<GoogleMap> {
518528
MapConfiguration _configurationFromMapWidget(GoogleMap map) {
519529
assert(!map.liteModeEnabled || Platform.isAndroid);
520530
return MapConfiguration(
531+
webGestureHandling: map.webGestureHandling,
521532
compassEnabled: map.compassEnabled,
522533
mapToolbarEnabled: map.mapToolbarEnabled,
523534
cameraTargetBounds: map.cameraTargetBounds,
@@ -526,6 +537,7 @@ MapConfiguration _configurationFromMapWidget(GoogleMap map) {
526537
rotateGesturesEnabled: map.rotateGesturesEnabled,
527538
scrollGesturesEnabled: map.scrollGesturesEnabled,
528539
tiltGesturesEnabled: map.tiltGesturesEnabled,
540+
fortyFiveDegreeImageryEnabled: map.fortyFiveDegreeImageryEnabled,
529541
trackCameraPosition: map.onCameraMove != null,
530542
zoomControlsEnabled: map.zoomControlsEnabled,
531543
zoomGesturesEnabled: map.zoomGesturesEnabled,

packages/google_maps_flutter/google_maps_flutter/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: google_maps_flutter
22
description: A Flutter plugin for integrating Google Maps in iOS and Android applications.
33
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
5-
version: 2.3.1
5+
version: 2.4.0
66

77
environment:
88
sdk: ">=3.0.0 <4.0.0"
@@ -23,8 +23,8 @@ dependencies:
2323
sdk: flutter
2424
google_maps_flutter_android: ^2.1.10
2525
google_maps_flutter_ios: ^2.1.10
26-
google_maps_flutter_platform_interface: ^2.2.1
27-
google_maps_flutter_web: ^0.5.0
26+
google_maps_flutter_platform_interface: ^2.4.0
27+
google_maps_flutter_web: ^0.5.2
2828

2929
dev_dependencies:
3030
flutter_test:

0 commit comments

Comments
 (0)