我正在使用Google Maps Utils对标记进行分组。现在我想自定义群集图标并执行此操作我正在使用此代码
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
}
}
但在markerOptions!!.icon
Android Studio上说val cannot be reassigned
。我该如何将自定义图标分配给markerOptions
实例?
答案 0 :(得分:0)
正如asm0dey所说,分配图标的正确方法是
minOccurs="0"