Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
separate info window visibility check and small iOS logic fixes
  • Loading branch information
jokerttu committed Apr 23, 2025
commit 8f417df31a3be4443439a54d40f1612eb12d2586
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,43 @@ void main() {
});

testWidgets('testToggleInfoWindow', (WidgetTester tester) async {
const Marker marker = Marker(
markerId: MarkerId('marker'),
infoWindow: InfoWindow(title: 'InfoWindow'));
final Set<Marker> markers = <Marker>{marker};

final Completer<ExampleGoogleMapController> controllerCompleter =
Completer<ExampleGoogleMapController>();

await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr,
child: ExampleGoogleMap(
initialCameraPosition: const CameraPosition(target: LatLng(10.0, 15.0)),
markers: markers,
onMapCreated: (ExampleGoogleMapController googleMapController) {
controllerCompleter.complete(googleMapController);
},
),
));

final ExampleGoogleMapController controller =
await controllerCompleter.future;

bool iwVisibleStatus =
await controller.isMarkerInfoWindowShown(marker.markerId);
expect(iwVisibleStatus, false);

await controller.showMarkerInfoWindow(marker.markerId);
iwVisibleStatus = await controller.isMarkerInfoWindowShown(marker.markerId);
expect(iwVisibleStatus, true);

await controller.hideMarkerInfoWindow(marker.markerId);
iwVisibleStatus = await controller.isMarkerInfoWindowShown(marker.markerId);
expect(iwVisibleStatus, false);
});

testWidgets('updating a marker does not hide its info window',
(WidgetTester tester) async {
final Key key = GlobalKey();
const Marker marker = Marker(
markerId: MarkerId('marker'),
Expand Down Expand Up @@ -838,15 +875,13 @@ void main() {
final ExampleGoogleMapController controller =
await controllerCompleter.future;

await controller.showMarkerInfoWindow(marker.markerId);
bool iwVisibleStatus =
await controller.isMarkerInfoWindowShown(marker.markerId);
expect(iwVisibleStatus, false);

await controller.showMarkerInfoWindow(marker.markerId);
iwVisibleStatus = await controller.isMarkerInfoWindowShown(marker.markerId);
expect(iwVisibleStatus, true);

// Update marker and check if the info window is still visible.
// Update marker and ensure the info window remains visible when added to a
// cluster manager.
final Marker updatedMarker = marker.copyWith(
alphaParam: 0.5,
clusterManagerIdParam: clusterManager.clusterManagerId,
Expand All @@ -862,13 +897,8 @@ void main() {
markers: Set<Marker>.of(markers)),
));

await controller.showMarkerInfoWindow(marker.markerId);
iwVisibleStatus = await controller.isMarkerInfoWindowShown(marker.markerId);
expect(iwVisibleStatus, true);

await controller.hideMarkerInfoWindow(marker.markerId);
iwVisibleStatus = await controller.isMarkerInfoWindowShown(marker.markerId);
expect(iwVisibleStatus, false);
});

testWidgets('testTakeSnapshot', (WidgetTester tester) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,13 @@ - (void)updateFromPlatformMarker:(FGMPlatformMarker *)platformMarker
[self setInfoWindowTitle:infoWindow.title snippet:infoWindow.snippet];
}

[self setVisible:platformMarker.visible];

// Set the marker's user data with current identifiers.
FGMSetIdentifiersToMarkerUserData(self.markerIdentifier, self.clusterManagerIdentifier,
self.marker);

// Ensure setVisible is called last as it adds the marker to the map,
// and must be done after all other parameters are set.
[self setVisible:platformMarker.visible];
}

@end
Expand Down Expand Up @@ -215,7 +217,7 @@ - (void)changeMarker:(FGMPlatformMarker *)markerToChange {

if ([controller.marker conformsToProtocol:@protocol(GMUClusterItem)]) {
if (previousClusterManagerIdentifier &&
![previousClusterManagerIdentifier isEqualToString:clusterManagerIdentifier]) {
![clusterManagerIdentifier isEqualToString:previousClusterManagerIdentifier]) {
// Remove marker from previous cluster manager if its cluster manager identifier is removed or
// changed.
GMUClusterManager *clusterManager = [_clusterManagersController
Expand Down