I'm working with markers in a cluster (google maps), I have no problem in showing an info window when calling the onclick method. The problem is that I can't find how to use the method showInfoWindow() as I do on a marker to open the info without giving click.
When I use a marker
marker = map.addMarker(new MarkerOptions()
.position(position)
.snippet(info));
then I call
marker.showInfoWindow();
how I can do the same with a marker (ClusterItem) that is on the map within the cluster manager?
MarkCluster cluster = new MarkCluster(Lat, Lon, info);
mClusterManager.addItem(cluster);
Try this, its what I did to get references to map markers when using clustering:
When you create a
ClusterManager
it always creates and uses an instance of theDefaultClusterRenderer
if you don't call the.setRenderer()
method and pass it an instance of your ownClusterRenderer
implementation. If you are letting theClusterManager
create its ownDefaultClusterRenderer
the key is to add it explicitly so that you can keep a reference to it (because theClusterManager
has no getter method so you can get a reference to theClusterRenderer
its using):Then when you need access to a marker pass the
ClusterRenderer
theClusterItem
associated with the marker. TheClusterItem
you use to find the marker will be theClusterItem
you passed to theClusterManager
to add the marker to the cluster originally:The
Marker
object will be null if the marker has not been rendered on the map yet so be sure to check that the marker object is not null before using it.If you are certain the marker has been placed on the map when you call
.getMarker()
and marker is still null then override the.equals()
method in the object use to implement theClusterItem
Interface to make sure you can find the correctClusterItem
object held by the renderer.