Android-maps-utils: onClusterClick not called.

Created on 15 May 2015  路  3Comments  路  Source: googlemaps/android-maps-utils

Is anyone else having this issue? It's not hitting the breakpoint nor showing the log.

    mClusterManager.setOnClusterClickListener(new ClusterManager.OnClusterClickListener<Content>() {
        @Override
        public boolean onClusterClick(Cluster<Content> cluster) {
            AppLog.d("CLUSTER_CLICKED", "cluster is clicked);");
            return false;
        }
    });

I'm not sure if it helps, but I'm using a custom cluster adapter:

mapsMarkerManager.getClusterManager().getClusterMarkerCollection().setOnInfoWindowAdapter(new ClusterInfoWindowAdapter(getActivity(), mapsMarkerManager));

I'm using:
compile 'com.google.maps.android:android-maps-utils:0.3.1'

Most helpful comment

Oh, snap. Now it's working. Sorry about that. I didn't add this line:
googleMap.setOnMarkerClickListener(mClusterManager);

Apparently it's needed.

All 3 comments

Oh, snap. Now it's working. Sorry about that. I didn't add this line:
googleMap.setOnMarkerClickListener(mClusterManager);

Apparently it's needed.

This information took too long to find. Perhaps sample app could include an example?

To get click events one must:

  1. create and set appropriate click listener on your cluster manger
  2. tell the map that the cluster manager will handle these click events

Example:

mClusterManager.setOnClusterInfoWindowClickListener(...)
mClusterManager.setOnClusterItemInfoWindowClickListener(...)
mMap.setOnInfoWindowClickListener(mClusterManager);

Issue is same for info window and marker item clicks:

  • OnClusterItemInfoWindowClickListener
  • OnClusterInfoWindowClickListener
  • OnClusterClickListener
  • OnClusterItemClickListener

same as issue #184

The demo app does actually include an example of this: https://github.com/googlemaps/android-maps-utils/blob/b153c67ad589d5e03a6362f2349fb49e3cc70c8e/demo/src/com/google/maps/android/utils/demo/CustomMarkerClusteringDemoActivity.java#L159-L174

I think the real problem was lack of visible documentation here on GitHub. I've recently updated the project and README to point to the comprehensive guide on developers.google.com which includes details on setting up handlers for cluster events.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

syedalibumpin picture syedalibumpin  路  5Comments

Ricardo1980 picture Ricardo1980  路  7Comments

bedzinsa picture bedzinsa  路  7Comments

programmeraditya picture programmeraditya  路  5Comments

TatyanaRTB picture TatyanaRTB  路  3Comments