googlemaps / googlemaps/android-maps-utils
Missing animation when overridden shouldRenderAsCluster uses zoom level to decide
- Dominant language
- Kotlin
- Stars
- 3.6k
- Forks
- 1.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 17
Description
**Summary:**
Using zoom level to decide if a cluster should be rendered makes the animation of markers moving from the clusters towards their final position stop working. The markers just "appear".
**Steps to reproduce:**
Use a custom renderer like this to disable clusters on zoom level 15 and closer:
https://github.com/blurpy/android-maps-utils/blob/60398d9190028c82d231db69ba8404cfcb3274c3/demo/src/com/google/maps/android/utils/demo/CustomAnimationNotWorkingClusterRenderer.java
Zoom to you reach level 15.
I have a fork of the code with a modified demo app using this renderer: https://github.com/blurpy/android-maps-utils/tree/zoom-animation-bug
**Expected behavior:**
All zoom levels should display markers animating in and out of clusters.
**Observed behavior:**
Animations work on all zoom levels except the last one. The renderer has specified that no clusters should be rendered at zoom level 15 or closer. When reaching level 15 the markers just pop up instead of animating out of clusters.
**Solution?:**
I don't understand all the details of how this framework works, but I noticed that having two different callbacks to decide if a cluster should be rendered made animations work. Seems like the framework expects shouldRenderAsCluster to be "stable", as in returning the same result based on the same input. Using zoom level in the decision breaks that assumption.
See https://github.com/blurpy/android-maps-utils/commit/60398d9190028c82d231db69ba8404cfcb3274c3
This commit contains a custom renderer enabled by default that overrides the old shouldRenderAsCluster, and one that uses the new shouldRenderAsClusterForAnimation. Both tries to disable clusters at zoom level 15. Switch between them in the ClusteringDemoActivity to see the difference in behavior.
The change I made to make this work seems a bit hacky to me, so I didn't submit a pull request. Also don't know if it breaks something, but I'm using this in an app at the moment and haven't noticed any issues.
Note: this exact same issue (and workaround) happens in the iOS version of the framework (https://github.com/googlemaps/google-maps-ios-utils) as well.
Contributor guide
Assessment
This issue has not been assessed yet.