Reputation: 1064
I'm using the Google Maps Utils to group the markers. Now I want to customize the cluster icon and to do that I'm using this code
class ClusteredMarkerRender(context: Context, map: GoogleMap, clusterManager: ClusterManager<ClusteredMarker>)
: DefaultClusterRenderer<ClusteredMarker>(context, map, clusterManager) {
override fun onBeforeClusterRendered(cluster: Cluster<ClusteredMarker>?, markerOptions: MarkerOptions?) {
super.onBeforeClusterRendered(cluster, markerOptions)
markerOptions!!.icon = BitmapDescriptorFactory.fromResource(R.id.cluster_icon)
}
override fun shouldRenderAsCluster(cluster: Cluster<ClusteredMarker>?): Boolean {
return cluster!!.size > 1
}
}
but on markerOptions!!.icon
Android Studio says val cannot be reassigned
. How am I supposed to assign my custom icon to the markerOptions
instance?
Upvotes: 1
Views: 512
Reputation: 1064
As said by asm0dey, the correct way to assign the icon was
markerOptions!!.icon(BitmapDescriptorFactory.fromResource(R.id.cluster_icon))
Upvotes: 2