twotoasters / clusterkraf

A clustering library for the Google Maps Android API v2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add function to Zoom to Bounds when click in Cluster which has Info Window shown already

trietbui85 opened this issue · comments

OK, let me describe step by step how to archive it.

In advanced mode

  1. Cluster click behavior: choose Show Info Window
  2. Cluster Info Window Click behavior: choose Zoom to Bounds
  3. Open the Sample Activity. Click on a cluster, then the Info Window will be shown.
    In this case, if click the Info Window will perform Zoom to Bounds.
  4. I want to have an option, when the Info Window is shown, we can also click on Cluster to perform Zoom to Bounds action. At the moment, click on Cluster when Info Window is shown does nothing.

Thank you for great mapping cluster library.

Thanks for the suggestion, @anticafe!

Looking at the Google Maps API docs, it looks like it should be possible to implement this by adding an extra value in Options.ClusterClickBehavior and a check against Marker.isInfoWindowShown(). See https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/model/Marker#isInfoWindowShown()

Did you want to code this change? You could fork it, code it on your fork, and send a pull request. Let me know so we don't duplicate effort (I like the idea enough to implement it myself when I have time).

I just tried to implement this (see 13a1c60), but I think I stumbled across a bug in the Google Maps API v2. The problem is the marker.isInfoWindowVisible() returns false when the OnMarkerClickListener calls marker.showInfoWindow() and the onMarkerClick(Marker) returns true, so, even though the Info Window is clearly visible, it is not possible to accurately test its visibility programmatically. I'm going to try to repeat this problem in a more concise example, and then submit a bug report to the Google Maps API v2 bug tracker.

Bug filed: https://code.google.com/p/gmaps-api-issues/issues/detail?id=5408 -- @anticafe and anyone else wanting this feature implemented, please star the issue