diff --git a/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md index 52f288ec7e9..0427818ca50 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.5.2 + +* Adds options for gesture handling and tilt controls. + ## 0.5.1 * Adds padding support to `CameraUpdate.newLatLngBounds`. Issue [#122192](https://github.com/flutter/flutter/issues/122192). diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart index 8889e4ba957..00a448a979b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart @@ -383,6 +383,7 @@ void main() { mapConfiguration: const MapConfiguration( mapType: MapType.satellite, zoomControlsEnabled: true, + fortyFiveDegreeImageryEnabled: false, )); controller.debugSetOverrides( createMap: (_, gmaps.MapOptions options) { @@ -398,13 +399,16 @@ void main() { expect(capturedOptions!.gestureHandling, 'auto', reason: 'by default the map handles zoom/pan gestures internally'); + expect(capturedOptions!.rotateControl, false); + expect(capturedOptions!.tilt, 0); }); - testWidgets('disables gestureHandling with scrollGesturesEnabled false', + testWidgets('translates fortyFiveDegreeImageryEnabled option', (WidgetTester tester) async { controller = createController( mapConfiguration: const MapConfiguration( scrollGesturesEnabled: false, + fortyFiveDegreeImageryEnabled: true, )); controller.debugSetOverrides( createMap: (_, gmaps.MapOptions options) { @@ -415,16 +419,16 @@ void main() { controller.init(); expect(capturedOptions, isNotNull); - expect(capturedOptions!.gestureHandling, 'none', - reason: - 'disabling scroll gestures disables all gesture handling'); + expect(capturedOptions!.rotateControl, true); + expect(capturedOptions!.tilt, isNull); }); - testWidgets('disables gestureHandling with zoomGesturesEnabled false', + testWidgets('translates webGestureHandling option', (WidgetTester tester) async { controller = createController( mapConfiguration: const MapConfiguration( zoomGesturesEnabled: false, + webGestureHandling: WebGestureHandling.greedy, )); controller.debugSetOverrides( createMap: (_, gmaps.MapOptions options) { @@ -435,9 +439,7 @@ void main() { controller.init(); expect(capturedOptions, isNotNull); - expect(capturedOptions!.gestureHandling, 'none', - reason: - 'disabling scroll gestures disables all gesture handling'); + expect(capturedOptions!.gestureHandling, 'greedy'); }); testWidgets('sets initial position when passed', diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart index 1e3bcac753e..1e5e9192c45 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart @@ -31,7 +31,7 @@ double _getCssOpacity(Color color) { // myLocationEnabled needs to be built through dart:html navigator.geolocation // See: https://api.dart.dev/stable/2.8.4/dart-html/Geolocation-class.html // trafficEnabled is handled when creating the GMap object, since it needs to be added as a layer. -// trackCameraPosition is just a boolan value that indicates if the map has an onCameraMove handler. +// trackCameraPosition is just a boolean value that indicates if the map has an onCameraMove handler. // indoorViewEnabled seems to not have an equivalent in web // buildingsEnabled seems to not have an equivalent in web // padding seems to behave differently in web than mobile. You can't move UI elements in web. @@ -60,11 +60,18 @@ gmaps.MapOptions _configurationAndStyleToGmapsOptions( options.zoomControl = configuration.zoomControlsEnabled; } - if (configuration.scrollGesturesEnabled == false || + if (configuration.webGestureHandling != null) { + options.gestureHandling = configuration.webGestureHandling!.name; + } else if (configuration.scrollGesturesEnabled == false || configuration.zoomGesturesEnabled == false) { - options.gestureHandling = 'none'; + // Old behavior + options.gestureHandling = WebGestureHandling.none.name; } else { - options.gestureHandling = 'auto'; + options.gestureHandling = WebGestureHandling.auto.name; + } + + if (configuration.fortyFiveDegreeImageryEnabled != null) { + options.rotateControl = configuration.fortyFiveDegreeImageryEnabled; } // These don't have any configuration entries, but they seem to be off in the diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart index 41342bf5cff..f49a6878df5 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart @@ -169,6 +169,11 @@ class GoogleMapController { // Initial position can only to be set here! options = _applyInitialPosition(_initialCameraPosition, options); + // Fully disable 45 degree imagery if desired + if (options.rotateControl == false) { + options.tilt = 0; + } + // Create the map... final gmaps.GMap map = _createMap(_div, options); _googleMap = map; diff --git a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml index e6afb06eab3..f1eb09c6c57 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter_web description: Web platform implementation of google_maps_flutter repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_web issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 0.5.1 +version: 0.5.2 environment: sdk: ">=2.18.0 <4.0.0" @@ -22,7 +22,7 @@ dependencies: flutter_web_plugins: sdk: flutter google_maps: ^6.1.0 - google_maps_flutter_platform_interface: ^2.2.2 + google_maps_flutter_platform_interface: ^2.4.0 sanitize_html: ^2.0.0 stream_transform: ^2.0.0