mirror of
https://github.com/flutter/packages.git
synced 2025-06-29 14:18:54 +08:00
[google_maps_flutter_web] Adds options for gesture handling and tilt controls. (#4521)
See #3258
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
## 0.5.2
|
||||||
|
|
||||||
|
* Adds options for gesture handling and tilt controls.
|
||||||
|
|
||||||
## 0.5.1
|
## 0.5.1
|
||||||
|
|
||||||
* Adds padding support to `CameraUpdate.newLatLngBounds`. Issue [#122192](https://github.com/flutter/flutter/issues/122192).
|
* Adds padding support to `CameraUpdate.newLatLngBounds`. Issue [#122192](https://github.com/flutter/flutter/issues/122192).
|
||||||
|
@ -383,6 +383,7 @@ void main() {
|
|||||||
mapConfiguration: const MapConfiguration(
|
mapConfiguration: const MapConfiguration(
|
||||||
mapType: MapType.satellite,
|
mapType: MapType.satellite,
|
||||||
zoomControlsEnabled: true,
|
zoomControlsEnabled: true,
|
||||||
|
fortyFiveDegreeImageryEnabled: false,
|
||||||
));
|
));
|
||||||
controller.debugSetOverrides(
|
controller.debugSetOverrides(
|
||||||
createMap: (_, gmaps.MapOptions options) {
|
createMap: (_, gmaps.MapOptions options) {
|
||||||
@ -398,13 +399,16 @@ void main() {
|
|||||||
expect(capturedOptions!.gestureHandling, 'auto',
|
expect(capturedOptions!.gestureHandling, 'auto',
|
||||||
reason:
|
reason:
|
||||||
'by default the map handles zoom/pan gestures internally');
|
'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 {
|
(WidgetTester tester) async {
|
||||||
controller = createController(
|
controller = createController(
|
||||||
mapConfiguration: const MapConfiguration(
|
mapConfiguration: const MapConfiguration(
|
||||||
scrollGesturesEnabled: false,
|
scrollGesturesEnabled: false,
|
||||||
|
fortyFiveDegreeImageryEnabled: true,
|
||||||
));
|
));
|
||||||
controller.debugSetOverrides(
|
controller.debugSetOverrides(
|
||||||
createMap: (_, gmaps.MapOptions options) {
|
createMap: (_, gmaps.MapOptions options) {
|
||||||
@ -415,16 +419,16 @@ void main() {
|
|||||||
controller.init();
|
controller.init();
|
||||||
|
|
||||||
expect(capturedOptions, isNotNull);
|
expect(capturedOptions, isNotNull);
|
||||||
expect(capturedOptions!.gestureHandling, 'none',
|
expect(capturedOptions!.rotateControl, true);
|
||||||
reason:
|
expect(capturedOptions!.tilt, isNull);
|
||||||
'disabling scroll gestures disables all gesture handling');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('disables gestureHandling with zoomGesturesEnabled false',
|
testWidgets('translates webGestureHandling option',
|
||||||
(WidgetTester tester) async {
|
(WidgetTester tester) async {
|
||||||
controller = createController(
|
controller = createController(
|
||||||
mapConfiguration: const MapConfiguration(
|
mapConfiguration: const MapConfiguration(
|
||||||
zoomGesturesEnabled: false,
|
zoomGesturesEnabled: false,
|
||||||
|
webGestureHandling: WebGestureHandling.greedy,
|
||||||
));
|
));
|
||||||
controller.debugSetOverrides(
|
controller.debugSetOverrides(
|
||||||
createMap: (_, gmaps.MapOptions options) {
|
createMap: (_, gmaps.MapOptions options) {
|
||||||
@ -435,9 +439,7 @@ void main() {
|
|||||||
controller.init();
|
controller.init();
|
||||||
|
|
||||||
expect(capturedOptions, isNotNull);
|
expect(capturedOptions, isNotNull);
|
||||||
expect(capturedOptions!.gestureHandling, 'none',
|
expect(capturedOptions!.gestureHandling, 'greedy');
|
||||||
reason:
|
|
||||||
'disabling scroll gestures disables all gesture handling');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('sets initial position when passed',
|
testWidgets('sets initial position when passed',
|
||||||
|
@ -31,7 +31,7 @@ double _getCssOpacity(Color color) {
|
|||||||
// myLocationEnabled needs to be built through dart:html navigator.geolocation
|
// myLocationEnabled needs to be built through dart:html navigator.geolocation
|
||||||
// See: https://api.dart.dev/stable/2.8.4/dart-html/Geolocation-class.html
|
// 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.
|
// 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
|
// indoorViewEnabled seems to not have an equivalent in web
|
||||||
// buildingsEnabled 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.
|
// 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;
|
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) {
|
configuration.zoomGesturesEnabled == false) {
|
||||||
options.gestureHandling = 'none';
|
// Old behavior
|
||||||
|
options.gestureHandling = WebGestureHandling.none.name;
|
||||||
} else {
|
} 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
|
// These don't have any configuration entries, but they seem to be off in the
|
||||||
|
@ -169,6 +169,11 @@ class GoogleMapController {
|
|||||||
// Initial position can only to be set here!
|
// Initial position can only to be set here!
|
||||||
options = _applyInitialPosition(_initialCameraPosition, options);
|
options = _applyInitialPosition(_initialCameraPosition, options);
|
||||||
|
|
||||||
|
// Fully disable 45 degree imagery if desired
|
||||||
|
if (options.rotateControl == false) {
|
||||||
|
options.tilt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Create the map...
|
// Create the map...
|
||||||
final gmaps.GMap map = _createMap(_div, options);
|
final gmaps.GMap map = _createMap(_div, options);
|
||||||
_googleMap = map;
|
_googleMap = map;
|
||||||
|
@ -2,7 +2,7 @@ name: google_maps_flutter_web
|
|||||||
description: Web platform implementation of google_maps_flutter
|
description: Web platform implementation of google_maps_flutter
|
||||||
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_web
|
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
|
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:
|
environment:
|
||||||
sdk: ">=2.18.0 <4.0.0"
|
sdk: ">=2.18.0 <4.0.0"
|
||||||
@ -22,7 +22,7 @@ dependencies:
|
|||||||
flutter_web_plugins:
|
flutter_web_plugins:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
google_maps: ^6.1.0
|
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
|
sanitize_html: ^2.0.0
|
||||||
stream_transform: ^2.0.0
|
stream_transform: ^2.0.0
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user