Android Google 地图集群图标忽略自定义图标
Android Google Map Cluster icon ignores custom icon
Android Google 地图群集图标在缩小时忽略自定义图标。有什么解决方法的建议吗?
override fun onBeforeClusterRendered(cluster: Cluster<T>, markerOptions: MarkerOptions) {
mClusterIconGenerator.setBackground(context?.let { ContextCompat.getDrawable(it, R.drawable.map_cluster_item) })
mClusterIconGenerator.setTextAppearance(R.style.WhiteTextAppearance)
val icon = mClusterIconGenerator.makeIcon(cluster.size.toString())
markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon));
}
已修复 getDescriptorForCluster
private val mClusterIconGenerator = IconGenerator(context).apply {
setBackground(context?.let { ContextCompat.getDrawable(it, R.drawable.map_cluster_item) })
setTextAppearance(R.style.WhiteTextAppearance)
}
override fun onBeforeClusterRendered(cluster: Cluster<T>, markerOptions: MarkerOptions) {
val icon = mClusterIconGenerator.makeIcon(cluster.size.toString())
markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon));
}
override fun getDescriptorForCluster(cluster: Cluster<T>): BitmapDescriptor {
val icon = mClusterIconGenerator.makeIcon(cluster.size.toString())
return BitmapDescriptorFactory.fromBitmap(icon)
}
Android Google 地图群集图标在缩小时忽略自定义图标。有什么解决方法的建议吗?
override fun onBeforeClusterRendered(cluster: Cluster<T>, markerOptions: MarkerOptions) {
mClusterIconGenerator.setBackground(context?.let { ContextCompat.getDrawable(it, R.drawable.map_cluster_item) })
mClusterIconGenerator.setTextAppearance(R.style.WhiteTextAppearance)
val icon = mClusterIconGenerator.makeIcon(cluster.size.toString())
markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon));
}
已修复 getDescriptorForCluster
private val mClusterIconGenerator = IconGenerator(context).apply {
setBackground(context?.let { ContextCompat.getDrawable(it, R.drawable.map_cluster_item) })
setTextAppearance(R.style.WhiteTextAppearance)
}
override fun onBeforeClusterRendered(cluster: Cluster<T>, markerOptions: MarkerOptions) {
val icon = mClusterIconGenerator.makeIcon(cluster.size.toString())
markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon));
}
override fun getDescriptorForCluster(cluster: Cluster<T>): BitmapDescriptor {
val icon = mClusterIconGenerator.makeIcon(cluster.size.toString())
return BitmapDescriptorFactory.fromBitmap(icon)
}