googlemaps / android-maps-compose

Jetpack Compose composables for the Maps SDK for Android
https://developers.google.com/maps/documentation/android-sdk/maps-compose
Apache License 2.0
1.14k stars 135 forks source link

Clustering should support diff util #504

Open MikolajKakol opened 8 months ago

MikolajKakol commented 8 months ago

Is your feature request related to a problem? Please describe. My map has millions of points so I cannot add all of them at once. Hence what map moves I download items only visible on screen. When user does only small map movements points and clusters flicker and animations looks bad. This is because current implementation look like this:

    LaunchedEffect(itemsState) {
        snapshotFlow { itemsState.value.toList() }
            .collect { items ->
                clusterManager.clearItems()
                clusterManager.addItems(items)
                clusterManager.cluster()
            }
    }

So when ever items are updated clustering is recreated.

Describe the solution you'd like I think we should be able to provide some diffing to only add or remove a subset of items.

Describe alternatives you've considered I also though about just coping whole Clustering method and add custom logic, but it's not possible to reuse ResetMapListeners method.

wangela commented 8 months ago

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

@MikolajKakol 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.

PabloJuice commented 8 months ago

Absolutely agree! 👍 This would be a valuable addition. Let's prioritize this!

kikoso commented 8 months ago

Hi @MikolajKakol ,

Did you check the sample using the NonHierarchicalViewBasedAlgorithm? This only renders the screen content.

MikolajKakol commented 8 months ago

Hi @kikoso, it would be possible solution if I could populate map with all points from backend, but it is not possible to fetch all of them.