When adding multiple Clustering composables: onClusterItemClick callbacks are only done for the last added Clustering #294
Labels
priority: p1
Important issue which blocks shipping the next release. Will be fixed prior to next release.
released
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Environment details
Google maps sdk: android-maps-compose version 2.11.2 on Android emulator API 31
com.google.maps.android:maps-compose:2.11.2
Steps to reproduce
When adding multiple Clustering composables, (to cluster equal markertypes ) the onClusterItemClick is only called for the last added Clustering.
Rendering of markers and clusters for different clusterings all works as expected, only click handeling fails for me, so I can not put in my own selected state for a marker.
To verify the issue outside of my code I altered the MapClusteringActivity example by adding two Clustering composables for 1 map.
See code below. When clicking on a marker of 1 clustering logcat will show the debug message: "Cluster item clicked! $it". When clicking an item of the other clustering, no debug message is shown.
Probable cause
I have tracked the cause of the issue down to the MapApplier findInputCallback() extension method.
What happens is that for each Clustering an InputHandlerNode is added to decorations. When a marker is clicked findInputCallback() keeps searching for InputHandlerNode and always returns the last InputHandlerNode that is added.
Then the call continues in MarkerManage.java.onMarkerClick(Marker) where the marker is not found in the mAllObjects hashMap (as it is the MarkerManager of the last added Clustering) and the flow stops.
Copy of MapApplier findInputCallback() extension method:
Reproduce code:
The text was updated successfully, but these errors were encountered: