Android Google Map Cluster 图标忽略自定义图标
Posted
技术标签:
【中文标题】Android Google Map Cluster 图标忽略自定义图标【英文标题】:Android Google Map Cluster icon ignores custom icon 【发布时间】:2020-11-02 21:52:28 【问题描述】:android Google Map Cluster 图标在缩小时忽略自定义图标。有什么建议可以解决吗?
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));
【问题讨论】:
【参考方案1】:修复了覆盖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 Map Cluster 图标忽略自定义图标的主要内容,如果未能解决你的问题,请参考以下文章
无法解决:com.google.android.support.gms:play-services-map:10.2.0
android google map supportmap片段无法在片段中初始化
Android Google Map Marker 未正确重新定位