Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 3a4e307

Browse files
authored
[google_maps_flutter_web] Show one InfoWindow at a time. (#3224)
1 parent 5471420 commit 3a4e307

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.1.0+6
2+
3+
* Ensure a single `InfoWindow` is shown at a time. [Issue](https://github.com/flutter/flutter/issues/67380).
4+
15
## 0.1.0+5
26

37
* Update `package:google_maps` to `^3.4.5`.

packages/google_maps_flutter/google_maps_flutter_web/lib/src/markers.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class MarkersController extends GeometryController {
105105
///
106106
/// See also [hideMarkerInfoWindow] and [isInfoWindowShown].
107107
void showMarkerInfoWindow(MarkerId markerId) {
108+
_hideAllMarkerInfoWindow();
108109
MarkerController markerController = _markerIdToController[markerId];
109110
markerController?.showInfoWindow();
110111
}
@@ -145,4 +146,11 @@ class MarkersController extends GeometryController {
145146
markerId,
146147
));
147148
}
149+
150+
void _hideAllMarkerInfoWindow() {
151+
_markerIdToController.values
152+
.where((controller) =>
153+
controller == null ? false : controller.infoWindowShown)
154+
.forEach((controller) => controller.hideInfoWindow());
155+
}
148156
}

packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: google_maps_flutter_web
22
description: Web platform implementation of google_maps_flutter
33
homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter
4-
version: 0.1.0+5
4+
version: 0.1.0+6
55

66
flutter:
77
plugin:

packages/google_maps_flutter/google_maps_flutter_web/test/test_driver/markers_integration.dart

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,35 @@ void main() {
100100
expect(controller.markers[MarkerId('1')].infoWindowShown, isFalse);
101101
});
102102

103+
// https://github.com/flutter/flutter/issues/67380
104+
testWidgets('only single InfoWindow is visible',
105+
(WidgetTester tester) async {
106+
final markers = {
107+
Marker(
108+
markerId: MarkerId('1'),
109+
infoWindow: InfoWindow(title: "Title", snippet: "Snippet"),
110+
),
111+
Marker(
112+
markerId: MarkerId('2'),
113+
infoWindow: InfoWindow(title: "Title", snippet: "Snippet"),
114+
),
115+
};
116+
controller.addMarkers(markers);
117+
118+
expect(controller.markers[MarkerId('1')].infoWindowShown, isFalse);
119+
expect(controller.markers[MarkerId('2')].infoWindowShown, isFalse);
120+
121+
controller.showMarkerInfoWindow(MarkerId('1'));
122+
123+
expect(controller.markers[MarkerId('1')].infoWindowShown, isTrue);
124+
expect(controller.markers[MarkerId('2')].infoWindowShown, isFalse);
125+
126+
controller.showMarkerInfoWindow(MarkerId('2'));
127+
128+
expect(controller.markers[MarkerId('1')].infoWindowShown, isFalse);
129+
expect(controller.markers[MarkerId('2')].infoWindowShown, isTrue);
130+
});
131+
103132
// https://github.com/flutter/flutter/issues/64938
104133
testWidgets('markers with icon:null work', (WidgetTester tester) async {
105134
final markers = {

0 commit comments

Comments
 (0)