Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd cluster behavior during clustering #1316

Open
danijel-vrecic opened this issue Mar 12, 2024 · 1 comment
Open

Odd cluster behavior during clustering #1316

danijel-vrecic opened this issue Mar 12, 2024 · 1 comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@danijel-vrecic
Copy link

Summary

Weird cluster behaviour when clusters change with an animation on zooming. The cluster icon refreshes, resulting in a flickering shadow, even though the cluster position has not changed.
The shadow flicker is caused by a new cluster appearing on top of the existing one during the animation.

Expected behavior

I would expect the cluster to not animate if there is no position change. This would prevent a shadow flickering.

Observed behavior

When clusters are (re-)clustered, this also affects a cluster that has remained in the same position, causing the shadow to blink.

Screen_recording_20240312_133131ss.webm

Environment details

kotlin = "1.9.0"
mapUtils = "5.0.0"
playServicesMaps = "18.2.0"

Code example

Custom renderer with no additional modifications.

class CustomClusterRenderer(
    private val context: Context,
    map: GoogleMap,
    clusterManager: ClusterManager<MyItem>
) : DefaultClusterRenderer<MyItem>(context, map, clusterManager) {

    private val markerSize = context.resources.getDimensionPixelSize(R.dimen.marker_size)

    override fun onBeforeClusterItemRendered(item: MyItem, markerOptions: MarkerOptions) {
        markerOptions
            .icon(getIcon())
    }

    override fun onClusterItemRendered(clusterItem: MyItem, marker: Marker) {
        marker.run {
            setIcon(getIcon())
        }
    }

    override fun onBeforeClusterRendered(cluster: Cluster<MyItem>, markerOptions: MarkerOptions) {
        markerOptions.icon(getIcon())
    }

    override fun onClusterUpdated(cluster: Cluster<MyItem>, marker: Marker) {
        marker.setIcon(getIcon())
    }

    override fun shouldRenderAsCluster(cluster: Cluster<MyItem?>): Boolean {
        return cluster.size > 1
    }

    private fun getIcon(): BitmapDescriptor {
        val bitmap = BitmapFactory.decodeResource(context.resources, R.drawable.marker1)
            .scale(markerSize, markerSize, false)
        return BitmapDescriptorFactory.fromBitmap(bitmap);
    }
}
@danijel-vrecic danijel-vrecic added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Mar 12, 2024
@wangela
Copy link
Member

wangela commented Mar 12, 2024

If you would like to upvote the priority of this issue, please comment below or react on the original post above with 👍 so we can see what is popular when we triage.

@danijel-vrecic Thank you for opening this issue. 🙏
Please check out these other resources that might help you get to a resolution in the meantime:

This is an automated message, feel free to ignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants