Skip to content

Commit d9eee4c

Browse files
[google_maps_flutter] Add support for mapType, fullscreen, and Street View controls on web (flutter#11955)
This PR adds support for mapTypeControlEnabled, fullscreenControlEnabled, and streetViewControlEnabled on Flutter web. Previously, these options were not exposed through the GoogleMap widget and were internally defaulted to false in MapConfiguration. This change propagates these parameters through google_maps_flutter, google_maps_flutter_platform_interface, and google_maps_flutter_web, allowing developers to explicitly enable or disable these controls. To preserve backward compatibility, the existing behavior is maintained by defaulting these options to false when they are not provided by the user. I created a sample app and tested the changes using dependency_overrides. Attaching a video for reference. https://github.com/user-attachments/assets/014a50c4-e6d4-4325-8005-9d5d4b2db076 Fixes flutter#104111. ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 5f5ddfc commit d9eee4c

5 files changed

Lines changed: 104 additions & 4 deletions

File tree

‎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.18.0
2+
3+
* Adds support for mapTypeControlEnabled, fullscreenControlEnabled, and streetViewControlEnabled on web.
4+
15
## 2.17.1
26

37
* Updates README to link to implementation packages for platform-specific

‎packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies:
1919
# the parent directory to use the current plugin's version.
2020
path: ../
2121
google_maps_flutter_android: ^2.19.1
22-
google_maps_flutter_platform_interface: ^2.14.2
22+
google_maps_flutter_platform_interface: ^2.16.0
2323

2424
dev_dependencies:
2525
build_runner: ^2.1.10

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ class GoogleMap extends StatefulWidget {
103103
this.webCameraControlEnabled = true,
104104
this.compassEnabled = true,
105105
this.mapToolbarEnabled = true,
106+
this.mapTypeControlEnabled = false,
107+
this.fullscreenControlEnabled = false,
108+
this.streetViewControlEnabled = false,
106109
this.cameraTargetBounds = CameraTargetBounds.unbounded,
107110
this.mapType = MapType.normal,
108111
this.minMaxZoomPreference = MinMaxZoomPreference.unbounded,
@@ -374,6 +377,21 @@ class GoogleMap extends StatefulWidget {
374377
/// See https://developers.google.com/maps/documentation/javascript/controls for more details.
375378
final bool webCameraControlEnabled;
376379

380+
/// True if map type control should be shown.
381+
///
382+
/// Web only.
383+
final bool mapTypeControlEnabled;
384+
385+
/// True if fullscreen control should be shown.
386+
///
387+
/// Web only.
388+
final bool fullscreenControlEnabled;
389+
390+
/// True if street view control should be shown.
391+
///
392+
/// Web only.
393+
final bool streetViewControlEnabled;
394+
377395
/// Identifier that's associated with a specific cloud-based map style.
378396
///
379397
/// See https://developers.google.com/maps/documentation/get-map-id
@@ -724,6 +742,9 @@ MapConfiguration _configurationFromMapWidget(GoogleMap map) {
724742
webGestureHandling: map.webGestureHandling,
725743
compassEnabled: map.compassEnabled,
726744
mapToolbarEnabled: map.mapToolbarEnabled,
745+
mapTypeControlEnabled: map.mapTypeControlEnabled,
746+
fullscreenControlEnabled: map.fullscreenControlEnabled,
747+
streetViewControlEnabled: map.streetViewControlEnabled,
727748
cameraTargetBounds: map.cameraTargetBounds,
728749
mapType: map.mapType,
729750
minMaxZoomPreference: map.minMaxZoomPreference,

‎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.17.1
5+
version: 2.18.0
66

77
environment:
88
sdk: ^3.10.0
@@ -23,8 +23,8 @@ dependencies:
2323
sdk: flutter
2424
google_maps_flutter_android: ^2.19.1
2525
google_maps_flutter_ios: ^2.18.0
26-
google_maps_flutter_platform_interface: ^2.15.0
27-
google_maps_flutter_web: ^0.6.2
26+
google_maps_flutter_platform_interface: ^2.16.0
27+
google_maps_flutter_web: ^0.6.3
2828

2929
dev_dependencies:
3030
flutter_test:

‎packages/google_maps_flutter/google_maps_flutter/test/google_map_test.dart‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,81 @@ void main() {
108108
expect(map.mapConfiguration.mapToolbarEnabled, true);
109109
});
110110

111+
testWidgets('Can update mapTypeControlEnabled', (WidgetTester tester) async {
112+
await tester.pumpWidget(
113+
const Directionality(
114+
textDirection: TextDirection.ltr,
115+
child: GoogleMap(
116+
initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0)),
117+
mapTypeControlEnabled: true,
118+
),
119+
),
120+
);
121+
122+
final PlatformMapStateRecorder map = platform.lastCreatedMap;
123+
124+
expect(map.mapConfiguration.mapTypeControlEnabled, true);
125+
126+
await tester.pumpWidget(
127+
const Directionality(
128+
textDirection: TextDirection.ltr,
129+
child: GoogleMap(initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0))),
130+
),
131+
);
132+
133+
expect(map.mapConfiguration.mapTypeControlEnabled, false);
134+
});
135+
136+
testWidgets('Can update fullscreenControlEnabled', (WidgetTester tester) async {
137+
await tester.pumpWidget(
138+
const Directionality(
139+
textDirection: TextDirection.ltr,
140+
child: GoogleMap(
141+
initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0)),
142+
fullscreenControlEnabled: true,
143+
),
144+
),
145+
);
146+
147+
final PlatformMapStateRecorder map = platform.lastCreatedMap;
148+
149+
expect(map.mapConfiguration.fullscreenControlEnabled, true);
150+
151+
await tester.pumpWidget(
152+
const Directionality(
153+
textDirection: TextDirection.ltr,
154+
child: GoogleMap(initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0))),
155+
),
156+
);
157+
158+
expect(map.mapConfiguration.fullscreenControlEnabled, false);
159+
});
160+
161+
testWidgets('Can update streetViewControlEnabled', (WidgetTester tester) async {
162+
await tester.pumpWidget(
163+
const Directionality(
164+
textDirection: TextDirection.ltr,
165+
child: GoogleMap(
166+
initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0)),
167+
streetViewControlEnabled: true,
168+
),
169+
),
170+
);
171+
172+
final PlatformMapStateRecorder map = platform.lastCreatedMap;
173+
174+
expect(map.mapConfiguration.streetViewControlEnabled, true);
175+
176+
await tester.pumpWidget(
177+
const Directionality(
178+
textDirection: TextDirection.ltr,
179+
child: GoogleMap(initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0))),
180+
),
181+
);
182+
183+
expect(map.mapConfiguration.streetViewControlEnabled, false);
184+
});
185+
111186
testWidgets('Can update cameraTargetBounds', (WidgetTester tester) async {
112187
await tester.pumpWidget(
113188
Directionality(

0 commit comments

Comments
 (0)