Android Google Maps V2 Cluster hides infoWindow
In an Android project, I am using Google Maps Android API Utility Librairy to use a clustering solution.
On each individual marker or clustering marker, the InfoWindow opens when you tap the selected marker. Then when I click on infoWindow, I use the event theses:
...
mClusterManager.setOnClusterInfoWindowClickListener(this);
mClusterManager.setOnClusterItemInfoWindowClickListener(this);
...
and:
@Override
public void onClusterInfoWindowClick(Cluster<JobItem> cluster) {
// Here I go to a new fragment A, list of items.
}
@Override
public void onClusterItemInfoWindowClick(JobItem item) {
// Here I go to a new fragment B, item details
}
When I go back to the map (popBackStack from fragment A or B), the info window is always open. I would like to hide them programmatically when I go to snippet A or B. I found it possible to call hideInfoWindow () methods from the markers object, but in the theses of the two events the markers do not pass through the parameters.
Any idea on how to hide the infoWindow?
source to share
I found a solution that works for me, add this code to onResume of your fragment, it will close all open InfoWindow.
java.util.Collection<Marker> markerCollection = mClusterManager.getMarkerCollection().getMarkers();
for(Marker m : markerCollection){
if(m.isInfoWindowShown())
m.hideInfoWindow();
}
source to share