Skip to content

[google_maps_flutter_web] Adds options for gesture handling and tilt controls. #4521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ void main() {
mapConfiguration: const MapConfiguration(
mapType: MapType.satellite,
zoomControlsEnabled: true,
fortyFiveDegreeImageryEnabled: false,
));
controller.debugSetOverrides(
createMap: (_, gmaps.MapOptions options) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand Down