I'm using GoogleMaps clustering. I have 4 different types of markers, each extends from one abstract class, each has its owm icon and it defined in MarkerOptions field. I use ClusterManager for this abstract class. When I just use
//marker is instance of one of extended classes and has abstract class type
clusterManager.addItem(marker);
After clustering it sets icon to default. How I can fix this? I was trying to use something like this:
//marker is abstract marker, getMarker returns the MarkerOptions of this marker
clusterManager.getMarkerCollection().addMarker(marker.getMarker());
but it doesn't work too, marker is printed with needed icon on map, but without clustering.
Should I create create some method in my abstract class or there are some way to do this extending from DefaultClusterRenderer? I haven't found some information about it using Google or learning google maps lib.
Thanks for helping!
So, it was my foolish. Again, it shows, that I should pay more attention, studying library. If somebody is interested in answer, here it is: I was right supposing, that I need to override some method in DefaultClusterRenderer. So, the full way: Create own class and extend it from DefaultClusterRenderer:
public class OwnIconRendered extends DefaultClusterRenderer<AbstractMarker>
Then override method onBeforeClusterItemRendered:
@Override
protected void onBeforeClusterItemRendered(AbstractMarker item,
MarkerOptions markerOptions) {
markerOptions.icon(item.getMarker().getIcon());
}
The way is rather simple, but it seems to me, that clustering started to work slower. So, that's enough.