简体   繁体   English

android-maps-utils 中的 DefaultClusterRenderer 在 v1.2.1 中是否损坏?

[英]Is DefaultClusterRenderer in android-maps-utils broken in v1.2.1?

When trying to override any functions in DefaultClusterRenderer, it will not compile in v1.2.1.当试图覆盖 DefaultClusterRenderer 中的任何函数时,它不会在 v1.2.1 中编译。 All seems ok in v1.1.0 v1.1.0 中一切正常

In here I want to set colors to the clustericons, and overrides the DefaultClusterRenderer onBeforeClusterItemRendered to set the colors according to a value.在这里,我想将 colors 设置为 clustericons,并覆盖DefaultClusterRenderer onBeforeClusterItemRendered以根据值设置 colors。

Following code fails with v1.2.1, is perfectly ok in v1.1.0以下代码在 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)
    }


}

Do any know what has changed, and how to fix?有谁知道发生了什么变化,以及如何解决?

RG RG

I found the solution to the problem, in this pull ( https://github.com/googlemaps/android-maps-utils/pull/687 ) they changed the parameters to be nullsafe, so when changing:我找到了问题的解决方案,在这个拉( https://github.com/googlemaps/android-maps-utils/pull/687 )中,他们将参数更改为 nullsafe,所以在更改时:

override fun onBeforeClusterItemRendered(
    item: ClusterStation?,
    markerOptions: MarkerOptions?
)

to

override fun onBeforeClusterItemRendered(
    item: ClusterStation, 
    markerOptions: MarkerOptions
)

fixed it.解决它。 It is actually a kotlin issue...它实际上是一个 kotlin 问题......

RG RG

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 android-maps-utils for Java? - android-maps-utils for Java? 来自android:cluster-maps-utils的ClusterManager已更改且不具有后向兼容性 - ClusterManager from android:android-maps-utils changed and is not retrocompatible 使用android-maps-utils禁用最大缩放级别的群集 - Disable clustering at max zoom level using android-maps-utils 使用Googles android-maps-utils以最大缩放级别禁用群集 - Disable clustering at max zoom level with Googles android-maps-utils 无法通过Gradle导入com.google.maps.android:android-maps-utils - Can't import com.google.maps.android:android-maps-utils via gradle 安装Google Maps SDK for Android实用程序设置时出现问题(android-maps-utils) - problem installing Maps SDK for Android Utility Setup (android-maps-utils) 无法解析com.google.maps.android:android-maps-utils:0.5+ - Could not resolve com.google.maps.android:android-maps-utils:0.5+ &#39;com.google.maps.android:android-maps-utils:1.0.1&#39; 在聚类时中断,:1.0.0 不会 - 'com.google.maps.android:android-maps-utils:1.0.1' breaks on clustering, :1.0.0 does not 无法解决:com.google.maps.android:android-maps-utils:0.4+ - Failed to resolve: com.google.maps.android:android-maps-utils:0.4+ Android Maps utils上的Quadtree - Quadtree on android maps utils
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM