In my Android project I am using the android-maps-utils library to apply clustering to a bunch of markers on a map view. Whenever a marker is clicked I get notified via onClusterItemClick
so I can do some action.
public interface OnClusterItemClickListener<T extends ClusterItem> {
public boolean onClusterItemClick(T item);
}
Now I would like to let the user know which marker has been clicked. The easies visual feedback would be to change the (color of the) marker icon. A icon can be set via the MarkerOptions
object which can be access within onBeforeClusterItemRendered(T item, MarkerOptions markerOptions)
such as here:
markerOptions.icon(
BitmapDescriptorFactory.defaultMarker(
BitmapDescriptorFactory.HUE_YELLOW));
If I would have access to the Marker
object itself such as in onMarkerClick (Marker marker)
I could change the icon via setIcon
.
How can I change the clicked marker icon?
I noticed that the
DefaultClusterRenderer
provides methods to retrieve theMarker
object associated with aClusterItem
. Since I use a custom renderer anyways I was able to access the desiredMarker
object as shown here:This allows me to change the icon within
onClusterItemClick()
: