Git Product home page Git Product logo

Comments (2)

aidenfry avatar aidenfry commented on August 17, 2024

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.

from clusterkraf.

nealsanche avatar nealsanche commented on August 17, 2024

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.

from clusterkraf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.