Open nealsanche opened 11 years ago
Your correct, I created a fix from outside the library, this gets triggered after onClusteringFishished(). You will need to change slightly to fit your MarkerModel system.
new Thread(new Runnable() {
@Override
public void run() {
ArrayList<ClusterPoint> clusters = mClusterkraf.getClusterPoints();
if (clusters == null){
return;
}
//Get selected item ID (not relying on cluster Library) You need to keep a reference yourself to the selected item
Item selectedItem = getSelectedItem();
if (selectedHotspot==null){
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
//Selected is null hide all
mClusterkraf.hideAllInfoWindows();
}
});
return;
}
ClusterPoint selectedCluster = null;
int markerOffset = 0;
//Find the selected cluster
for (ClusterPoint cluster :clusters){
int size = cluster.size();
//search each point within the cluster
for (int i = 0 ; i < size ; i++){
MapMarkerModel model = (MapMarkerModel) cluster.getPointAtOffset(i).getTag();
//If ID = selected hotspot ID
if (model.uid == selectedItem.getUID()){
selectedCluster = cluster;
//we found it so jump out of this loop
break;
}
}
if (selectedCluster!=null){
break;
}
markerOffset++;
}
final ClusterPoint finalCluster = selectedCluster;
Marker marker;
try{
//get the marker which contains the cluster
marker = mClusterkraf.getMarkers().get(markerOffset);
}catch(Exception e){
return;
}
final Marker finalMarker = marker;
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
//Show info window for this cluster
mClusterkraf.showInfoWindow(finalMarker, finalCluster);
}
});
}
}).start();
Obviously this isn't optimal however it works, make sure to do most of the looping on a background thread to avoid UI pauses.
Seems rather heavy. I might try and figure out an easy way from inside the library to make this work, at some point. So far I have not been successful.
It seems that a cluster transition is started whenever the map is panned, regardless of whether clusters need to be transitioned, leading to a call to clusterkaf.removePreviousMarkers() which removes the markers. This means that if someone clicks on a marker to show its info-window, and then tries to pan the map to see more of the info-window, the info-window will dissapear.
I've been looking at trying to fix this issue. I'm not sure it's an easy one. So I'm reporting it.