Android cluster and marker clicks

前端 未结 4 2014
执笔经年
执笔经年 2020-12-03 05:56

I\'m using the android clustering utility on a map and succesffuly implemented an onclick listener with mClusterManager.setOnClusterItemClickListener() for all the markers h

4条回答
  •  醉酒成梦
    2020-12-03 06:09

    You can create a new MarkerManager that you pass into the ClusterManager constructor. Then make a new Marker collection using MarkerManager#newCollection and add your normal Markers to the map using the MarkerManager.Collection#addMarker method.

    Then, instead of calling mMap.setOnMarkerClickListener(mClusterManager), call mMap.setOnMarkerClickListener(mMarkerManager), and it will handle forwarding your Marker click events to the proper listeners. You'll also need to set up your onMarkerClick listener for normal Markers with the MarkerManager.Collection#setOnMarkerClickListener(GoogleMap.OnMarkerClickListener markerClickListener) function.

    I recommend looking over the source of the MarkerManager and ClusterManager classes to get a better idea of how the classes interact.

提交回复
热议问题