0

So I have around 850 markers that I have on my map, and I have already implemented the cluster manager successfully, but I can't seem to figure out how I can set each marker's title (which I have kept in a list). I have already tried the below code, but all of the marker's title's are then set to the first item in the list. Any thoughts?

Jacob

Here is the code I've tried (where universityName is the list)

mClusterManager.getMarkerCollection().setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
                @Override
                public boolean onMarkerClick(Marker marker) {
                    for(int i = 0; i < 835; i++) {
                        marker.setTitle(universityName.get(i));

                    }
                    return false;
                }
            });

Here is my MyClass:

class MyItem implements ClusterItem {
    private final LatLng mPosition;


    public MyItem(double lat, double lng) {
        mPosition = new LatLng(lat, lng);





    }

    @Override
    public LatLng getPosition() {
        return mPosition;
    }


}
Jacob Platin
  • 319
  • 3
  • 11
  • Do you have a `MyItem` class, as they have in the examples? You will need to use the ClusterManager instead of the traditional way of storing the Title in the Marker. – Daniel Nugent Jul 08 '15 at 22:04
  • @DanielNugent Yes, I have set up the MyItem class as such: MyItem offsetItem = new MyItem(universityLatLng.get(i).latitude, universityLatLng.get(i).longitude); mClusterManager.addItem(offsetItem); – Jacob Platin Jul 08 '15 at 22:06
  • Ok, you will need to add a Title to your MyItem class. Take a look at my other answer here: http://stackoverflow.com/questions/30958224/android-maps-utils-clustering-show-infowindow/30959578#30959578 I'll try to simplify it a bit for your example. Do you just need the Title to show in the InfoWindow? – Daniel Nugent Jul 08 '15 at 22:13
  • @DanielNugent You're other answer is awesome; thanks for the help! – Jacob Platin Jul 08 '15 at 22:21
  • Sure, no problem! Let me know if you can figure it out from that answer, you should be able to strip it down to just what you need. The key is to add each Title to the MyItem instance when you add each Marker. – Daniel Nugent Jul 08 '15 at 22:23

0 Answers0