diff --git a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md index 3dcd5bd12f93..04593fa9794b 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.17.2 + +* Add support for mapTypeControlEnabled, fullscreenControlEnabled, streetViewControlEnabled on web. + ## 2.17.1 * Updates README to link to implementation packages for platform-specific 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 3bd76b784571..d90b7aa175b4 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 @@ -103,6 +103,9 @@ class GoogleMap extends StatefulWidget { this.webCameraControlEnabled = true, this.compassEnabled = true, this.mapToolbarEnabled = true, + this.mapTypeControlEnabled = false, + this.fullscreenControlEnabled = false, + this.streetViewControlEnabled = false, this.cameraTargetBounds = CameraTargetBounds.unbounded, this.mapType = MapType.normal, this.minMaxZoomPreference = MinMaxZoomPreference.unbounded, @@ -374,6 +377,21 @@ class GoogleMap extends StatefulWidget { /// See https://developers.google.com/maps/documentation/javascript/controls for more details. final bool webCameraControlEnabled; + /// True if map type control should be shown. + /// + /// Web only. + final bool mapTypeControlEnabled; + + /// True if fullscreen control should be shown. + /// + /// Web only. + final bool fullscreenControlEnabled; + + /// True if street view control should be shown. + /// + /// Web only. + final bool streetViewControlEnabled; + /// Identifier that's associated with a specific cloud-based map style. /// /// See https://developers.google.com/maps/documentation/get-map-id @@ -724,6 +742,9 @@ MapConfiguration _configurationFromMapWidget(GoogleMap map) { webGestureHandling: map.webGestureHandling, compassEnabled: map.compassEnabled, mapToolbarEnabled: map.mapToolbarEnabled, + mapTypeControlEnabled: map.mapTypeControlEnabled, + fullscreenControlEnabled: map.fullscreenControlEnabled, + streetViewControlEnabled: map.streetViewControlEnabled, cameraTargetBounds: map.cameraTargetBounds, mapType: map.mapType, minMaxZoomPreference: map.minMaxZoomPreference, diff --git a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml index 0342292634b8..92548bc35087 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 @@ name: google_maps_flutter 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.17.1 +version: 2.17.2 environment: sdk: ^3.10.0 @@ -23,8 +23,8 @@ dependencies: sdk: flutter google_maps_flutter_android: ^2.19.1 google_maps_flutter_ios: ^2.18.0 - google_maps_flutter_platform_interface: ^2.15.0 - google_maps_flutter_web: ^0.6.2 + google_maps_flutter_platform_interface: ^2.15.1 + google_maps_flutter_web: ^0.6.3 dev_dependencies: flutter_test: diff --git a/packages/google_maps_flutter/google_maps_flutter/test/google_map_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/google_map_test.dart index 722a4390bb65..e284ed1d87e7 100644 --- a/packages/google_maps_flutter/google_maps_flutter/test/google_map_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter/test/google_map_test.dart @@ -108,6 +108,81 @@ void main() { expect(map.mapConfiguration.mapToolbarEnabled, true); }); + testWidgets('Can update mapTypeControlEnabled', (WidgetTester tester) async { + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: GoogleMap( + initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0)), + mapTypeControlEnabled: true, + ), + ), + ); + + final PlatformMapStateRecorder map = platform.lastCreatedMap; + + expect(map.mapConfiguration.mapTypeControlEnabled, true); + + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: GoogleMap(initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0))), + ), + ); + + expect(map.mapConfiguration.mapTypeControlEnabled, false); + }); + + testWidgets('Can update fullscreenControlEnabled', (WidgetTester tester) async { + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: GoogleMap( + initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0)), + fullscreenControlEnabled: true, + ), + ), + ); + + final PlatformMapStateRecorder map = platform.lastCreatedMap; + + expect(map.mapConfiguration.fullscreenControlEnabled, true); + + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: GoogleMap(initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0))), + ), + ); + + expect(map.mapConfiguration.fullscreenControlEnabled, false); + }); + + testWidgets('Can update streetViewControlEnabled', (WidgetTester tester) async { + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: GoogleMap( + initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0)), + streetViewControlEnabled: true, + ), + ), + ); + + final PlatformMapStateRecorder map = platform.lastCreatedMap; + + expect(map.mapConfiguration.streetViewControlEnabled, true); + + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: GoogleMap(initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0))), + ), + ); + + expect(map.mapConfiguration.streetViewControlEnabled, false); + }); + testWidgets('Can update cameraTargetBounds', (WidgetTester tester) async { await tester.pumpWidget( Directionality( diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md index 1c2d3c2fb1ca..8451b7ffeb80 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md @@ -2,6 +2,10 @@ * Updates minimum supported SDK version to Flutter 3.38/Dart 3.10. +## 2.15.1 + +* Add support for mapTypeControlEnabled, fullscreenControlEnabled, streetViewControlEnabled on web. + ## 2.15.0 * Adds support for `colorScheme` for cloud-based maps styling brightness in web. diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart index b1b13ec4a73d..ed96f70f9bd6 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart @@ -37,6 +37,9 @@ class MapConfiguration { this.indoorViewEnabled, this.trafficEnabled, this.buildingsEnabled, + this.mapTypeControlEnabled, + this.fullscreenControlEnabled, + this.streetViewControlEnabled, String? mapId, @Deprecated('cloudMapId is deprecated. Use mapId instead.') String? cloudMapId, this.style, @@ -67,6 +70,21 @@ class MapConfiguration { /// True if the map toolbar should be shown. final bool? mapToolbarEnabled; + /// True if map type control should be shown. + /// + /// Web only. + final bool? mapTypeControlEnabled; + + /// True if fullscreen control should be shown. + /// + /// Web only. + final bool? fullscreenControlEnabled; + + /// True if street view control should be shown. + /// + /// Web only. + final bool? streetViewControlEnabled; + /// The bounds to display. final CameraTargetBounds? cameraTargetBounds; @@ -210,6 +228,15 @@ class MapConfiguration { indoorViewEnabled: indoorViewEnabled != other.indoorViewEnabled ? indoorViewEnabled : null, trafficEnabled: trafficEnabled != other.trafficEnabled ? trafficEnabled : null, buildingsEnabled: buildingsEnabled != other.buildingsEnabled ? buildingsEnabled : null, + mapTypeControlEnabled: mapTypeControlEnabled != other.mapTypeControlEnabled + ? mapTypeControlEnabled + : null, + fullscreenControlEnabled: fullscreenControlEnabled != other.fullscreenControlEnabled + ? fullscreenControlEnabled + : null, + streetViewControlEnabled: streetViewControlEnabled != other.streetViewControlEnabled + ? streetViewControlEnabled + : null, mapId: mapId != other.mapId ? mapId : null, style: style != other.style ? style : null, markerType: markerType != other.markerType ? markerType : null, @@ -244,6 +271,9 @@ class MapConfiguration { indoorViewEnabled: diff.indoorViewEnabled ?? indoorViewEnabled, trafficEnabled: diff.trafficEnabled ?? trafficEnabled, buildingsEnabled: diff.buildingsEnabled ?? buildingsEnabled, + mapTypeControlEnabled: diff.mapTypeControlEnabled ?? mapTypeControlEnabled, + fullscreenControlEnabled: diff.fullscreenControlEnabled ?? fullscreenControlEnabled, + streetViewControlEnabled: diff.streetViewControlEnabled ?? streetViewControlEnabled, mapId: diff.mapId ?? mapId, style: diff.style ?? style, markerType: diff.markerType ?? markerType, @@ -275,6 +305,9 @@ class MapConfiguration { indoorViewEnabled == null && trafficEnabled == null && buildingsEnabled == null && + mapTypeControlEnabled == null && + fullscreenControlEnabled == null && + streetViewControlEnabled == null && mapId == null && style == null && markerType == null && @@ -311,6 +344,9 @@ class MapConfiguration { indoorViewEnabled == other.indoorViewEnabled && trafficEnabled == other.trafficEnabled && buildingsEnabled == other.buildingsEnabled && + mapTypeControlEnabled == other.mapTypeControlEnabled && + fullscreenControlEnabled == other.fullscreenControlEnabled && + streetViewControlEnabled == other.streetViewControlEnabled && mapId == other.mapId && style == other.style && markerType == other.markerType && @@ -341,6 +377,9 @@ class MapConfiguration { indoorViewEnabled, trafficEnabled, buildingsEnabled, + mapTypeControlEnabled, + fullscreenControlEnabled, + streetViewControlEnabled, mapId, style, markerType, diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml index 226c23f7e39b..db0e629cec03 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/google_maps_f issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 2.15.0 +version: 2.15.1 environment: sdk: ^3.10.0 diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/map_configuration_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/map_configuration_test.dart index 5ed9e487b360..5e5e7d18e393 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/map_configuration_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/map_configuration_test.dart @@ -36,6 +36,9 @@ void main() { indoorViewEnabled: false, trafficEnabled: false, buildingsEnabled: false, + mapTypeControlEnabled: false, + fullscreenControlEnabled: false, + streetViewControlEnabled: false, style: 'diff base style', ); @@ -490,6 +493,42 @@ void main() { // The hash code should change. expect(empty.hashCode, isNot(diff.hashCode)); }); + + test('handle mapTypeControlEnabled', () async { + const diff = MapConfiguration(mapTypeControlEnabled: true); + + const empty = MapConfiguration(); + final MapConfiguration updated = diffBase.applyDiff(diff); + + expect(empty.applyDiff(diff), diff); + expect(diff.diffFrom(empty), diff); + expect(updated.mapTypeControlEnabled, true); + expect(empty.hashCode, isNot(diff.hashCode)); + }); + + test('handle fullscreenControlEnabled', () async { + const diff = MapConfiguration(fullscreenControlEnabled: true); + + const empty = MapConfiguration(); + final MapConfiguration updated = diffBase.applyDiff(diff); + + expect(empty.applyDiff(diff), diff); + expect(diff.diffFrom(empty), diff); + expect(updated.fullscreenControlEnabled, true); + expect(empty.hashCode, isNot(diff.hashCode)); + }); + + test('handle streetViewControlEnabled', () async { + const diff = MapConfiguration(streetViewControlEnabled: true); + + const empty = MapConfiguration(); + final MapConfiguration updated = diffBase.applyDiff(diff); + + expect(empty.applyDiff(diff), diff); + expect(diff.diffFrom(empty), diff); + expect(updated.streetViewControlEnabled, true); + expect(empty.hashCode, isNot(diff.hashCode)); + }); }); group('isEmpty', () { @@ -649,5 +688,23 @@ void main() { expect(diff.isEmpty, false); }); + + test('is false with mapTypeControlEnabled', () async { + const diff = MapConfiguration(mapTypeControlEnabled: true); + + expect(diff.isEmpty, false); + }); + + test('is false with fullscreenControlEnabled', () async { + const diff = MapConfiguration(fullscreenControlEnabled: true); + + expect(diff.isEmpty, false); + }); + + test('is false with streetViewControlEnabled', () async { + const diff = MapConfiguration(streetViewControlEnabled: true); + + expect(diff.isEmpty, false); + }); }); } 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 c8657c54f8d8..5944b8d3cc56 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.6.3 + +* Add support for mapTypeControlEnabled, fullscreenControlEnabled, streetViewControlEnabled on web. + ## 0.6.2+3 * Updates README to include setup information. diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/latest/integration_test/google_maps_controller_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/latest/integration_test/google_maps_controller_test.dart index bf1a77889f2b..a6262e3bf63e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/latest/integration_test/google_maps_controller_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/latest/integration_test/google_maps_controller_test.dart @@ -497,6 +497,66 @@ void main() { expect(capturedOptions!.cameraControl, isTrue); }); + testWidgets('translates mapTypeControlEnabled option', (WidgetTester tester) async { + gmaps.MapOptions? capturedOptions; + controller = createController( + mapConfiguration: const MapConfiguration( + mapTypeControlEnabled: true, + ), + ); + controller.debugSetOverrides( + createMap: (_, gmaps.MapOptions options) { + capturedOptions = options; + return map; + }, + ); + + controller.init(); + + expect(capturedOptions, isNotNull); + expect(capturedOptions!.mapTypeControl, isTrue); + }); + + testWidgets('translates fullscreenControlEnabled option', (WidgetTester tester) async { + gmaps.MapOptions? capturedOptions; + controller = createController( + mapConfiguration: const MapConfiguration( + fullscreenControlEnabled: true, + ), + ); + controller.debugSetOverrides( + createMap: (_, gmaps.MapOptions options) { + capturedOptions = options; + return map; + }, + ); + + controller.init(); + + expect(capturedOptions, isNotNull); + expect(capturedOptions!.fullscreenControl, isTrue); + }); + + testWidgets('translates streetViewControlEnabled option', (WidgetTester tester) async { + gmaps.MapOptions? capturedOptions; + controller = createController( + mapConfiguration: const MapConfiguration( + streetViewControlEnabled: true, + ), + ); + controller.debugSetOverrides( + createMap: (_, gmaps.MapOptions options) { + capturedOptions = options; + return map; + }, + ); + + controller.init(); + + expect(capturedOptions, isNotNull); + expect(capturedOptions!.streetViewControl, isTrue); + }); + testWidgets('translates webCameraControlPosition option', (WidgetTester tester) async { gmaps.MapOptions? capturedOptions; controller = createController( diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/latest/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/example/latest/pubspec.yaml index b5e0c77bbe65..7f69c74b24c7 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/latest/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/latest/pubspec.yaml @@ -8,7 +8,7 @@ environment: dependencies: flutter: sdk: flutter - google_maps_flutter_platform_interface: ^2.14.0 + google_maps_flutter_platform_interface: ^2.15.1 google_maps_flutter_web: path: ../.. web: ^1.0.0 @@ -34,3 +34,4 @@ dependency_overrides: # if we need to make a breaking change to google_maps_flutter_web. google_maps_flutter_web: path: ../.. + 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 99d7986fe308..517e129dba1a 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 @@ -113,11 +113,10 @@ gmaps.MapOptions _configurationAndStyleToGmapsOptions( options.rotateControl = configuration.fortyFiveDegreeImageryEnabled; } - // These don't have any configuration entries, but they seem to be off in the - // native maps. - options.mapTypeControl = false; - options.fullscreenControl = false; - options.streetViewControl = false; + // These are off by default in the native maps. + options.mapTypeControl = configuration.mapTypeControlEnabled ?? false; + options.fullscreenControl = configuration.fullscreenControlEnabled ?? false; + options.streetViewControl = configuration.streetViewControlEnabled ?? false; // Treat an empty mapId as null, as the app-facing package may pass it either // way. 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 9a19bffc4e88..1cb35834a982 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.6.2+3 +version: 0.6.3 environment: sdk: ^3.10.0 @@ -23,7 +23,7 @@ dependencies: flutter_web_plugins: sdk: flutter google_maps: ^8.1.0 - google_maps_flutter_platform_interface: ^2.15.0 + google_maps_flutter_platform_interface: ^2.15.1 sanitize_html: ^2.0.0 stream_transform: ^2.0.0 web: ^1.0.0 @@ -32,6 +32,7 @@ dev_dependencies: flutter_test: sdk: flutter + topics: - google-maps - google-maps-flutter