При попытке переопределить какие-либо функции в DefaultClusterRenderer, он не будет компилироваться в v1.2.1. Все выглядит нормально в v1.1.0
Здесь я хочу установить цвета для кластерингов и переопределять DefaultClusterRenderer
onBeforeClusterItemRendered
, чтобы установить цвета в соответствии со значением.
Следующий код не работает с v1.2.1, отлично работает с v1.1.0
package no.rogo.emptyfuel.utilities.cluster
import android.content.Context
import android.graphics.Color
import android.util.Log
import com.bumptech.glide.load.resource.bitmap.BitmapDrawableEncoder
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.model.BitmapDescriptorFactory
import com.google.android.gms.maps.model.Marker
import com.google.android.gms.maps.model.MarkerOptions
import com.google.maps.android.clustering.Cluster
import com.google.maps.android.clustering.ClusterManager
import com.google.maps.android.clustering.view.DefaultClusterRenderer
import com.google.maps.android.ui.IconGenerator
import no.rogo.emptyfuel.R
import no.rogo.emptyfuel.utilities.StatusLevel
/**
* Created by Roar on 05.04.2020.
* Copyright RoGo Software / Gronmo IT
*/
class CustomClusterRenderer(
context: Context,
map: GoogleMap,
clusterManager: ClusterManager<ClusterStation?>?
) : DefaultClusterRenderer<ClusterStation?>(context,map,clusterManager)
{
private val TAG by lazy { this::class.java.simpleName }
private val clusterIconGenerator = IconGenerator(context.applicationContext)
override fun onBeforeClusterItemRendered(
item: ClusterStation?,
markerOptions: MarkerOptions?
) {
var markerHue = when(item?.statusLevel)
{
StatusLevel.SINCE_NEW -> BitmapDescriptorFactory.HUE_GREEN
StatusLevel.SINCE_FAIR -> BitmapDescriptorFactory.HUE_YELLOW
StatusLevel.SINCE_OLD -> BitmapDescriptorFactory.HUE_RED
StatusLevel.SINCE_OLDER -> BitmapDescriptorFactory.HUE_BLUE
StatusLevel.NOT_SET -> BitmapDescriptorFactory.HUE_CYAN
StatusLevel.NOT_AVAILABLE -> BitmapDescriptorFactory.HUE_AZURE
StatusLevel.HIDDEN -> BitmapDescriptorFactory.HUE_ROSE
StatusLevel.UNCERTAIN -> BitmapDescriptorFactory.HUE_ORANGE
StatusLevel.UNKNOWN -> BitmapDescriptorFactory.HUE_MAGENTA
else -> BitmapDescriptorFactory.HUE_VIOLET
}
//Color.colorToHSV(markerColor,markerHue)
//Log.i(TAG,"map3: markerHue = ${markerHue[0]}")
val markerDescriptor = BitmapDescriptorFactory.defaultMarker(markerHue)
markerOptions?.icon(markerDescriptor)
super.onBeforeClusterItemRendered(item, markerOptions)
}
override fun onClusterItemRendered(clusterItem: ClusterStation?, marker: Marker?) {
super.onClusterItemRendered(clusterItem, marker)
}
override fun onBeforeClusterRendered(
cluster: Cluster<ClusterStation?>?,
markerOptions: MarkerOptions?
) {
super.onBeforeClusterRendered(cluster, markerOptions)
}
}
Кто-нибудь знает, что изменилось и как исправить?
RG