Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Info Windows dissapear when the map is panned. #28

Open
nealsanche opened this issue Oct 10, 2013 · 2 comments
Open

Info Windows dissapear when the map is panned. #28

nealsanche opened this issue Oct 10, 2013 · 2 comments

Comments

@nealsanche
Copy link

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.

@aidenfry
Copy link

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.

@nealsanche
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants