Hello everyone i m using this library and i m facing the strange issue basically i have implemented
maps using a supportMapFragment inside a fragment called called ExploreMaps when i click on the
cluster and cluster item for the first time it works but when go back to the other fragment and comes
back to this fragment the click functionality stops working.
Below is the code snippet from my code any help would be appreciated
private void setUpMaps(final BroadcastListWrapper wrapper) {
this.getMapAsync(mCallback = new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
Timber.d("set up maps called");
mClusterManager = new ClusterManager<>(getActivity(), googleMap);
googleMap.setOnCameraChangeListener(mClusterManager);
addItemsToCluster(wrapper);
googleMap.setInfoWindowAdapter(null);
mRenderer = new MapRenderer(getActivity(), googleMap, mClusterManager);
googleMap.setOnCameraChangeListener(mClusterManager);
googleMap.setOnMarkerClickListener(mClusterManager);
googleMap.setOnInfoWindowClickListener(mClusterManager);
mClusterManager.setRenderer(mRenderer);
mClusterManager.setOnClusterClickListener(ExploreMaps.this);
mClusterManager.setOnClusterItemClickListener(ExploreMaps.this);
}
});
}
@Override
public boolean onClusterItemClick(BroadcastData broadcastData) {
Timber.d("clusterITemclicked called");
return false;
}
@Override
public boolean onClusterClick(Cluster<BroadcastData> broadcastDataCluster) {
Timber.d("cluster click called");
showPopUp(broadcastDataCluster);
return false;
}
i finally solved the problem by removing the getSyncMap and its onReadyCallback methos
I am having the same problem. I have not used getSyncMap nor onReadyCallback. What is the solution??
Do you assign the mClustererManager on gmap onResume? Try to put an if clause so that you assign the clusterer only once. If you assign it in each resume then it will not work.
For me it's working in this way:
supportMapFragment.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
Log.d(getTagText(), "onMapReady");
googleMap.setMyLocationEnabled(true);
mGoogleMap = googleMap;
mClusterManager = new ClusterManager<>(getActivity(), googleMap);
mGoogleMap.setOnMarkerClickListener(mClusterManager);
mClusterManager.setRenderer(new CheckinClusterRenderer(getActivity(), googleMap, mClusterManager));
mClusterManager.setOnClusterItemClickListener(MapFragment.this);
}
});
Summarize: set the ClusterManager as MarkerClickListener and then onClusterItemClick() gets called
I solved the problem by clearing the map before using it as previous markers were drawn on top of new markers, thus preventing to trigger the click event.
getMapAsync(new OnMapReadyCallback() {
public void onMapReady(GoogleMap googleMap) {
googleMap.clear();
mClusterManager = new ClusterManager<>(getActivity(), googleMap);
...
}
}
Looks like a duplicate of #167
Most helpful comment
I solved the problem by clearing the map before using it as previous markers were drawn on top of new markers, thus preventing to trigger the click event.