Android Get The Markers That Are Not Clustered
I'm developing an android application and I'm using Google Maps Android API Utility Library. To be more specific I'm using the cluster part of that library. Now to my question: I'm
Solution 1:
I can recommend you another cool android-map library. Android Maps Extensions https://github.com/mg6maciej/android-maps-extensions
I use it in my app and it looks fine. It could be not easy to reimplement it in your app, but you could try.
To solve your problem you can make something like this:
List<Marker> markers = mMap.getDisplayedMarkers();
for (Marker marker : markers) {
if(!marker.isCluster()) {
//
}
}
Solution 2:
If you want to perform different tasks you might want to make different onClick events on clustered and single markers:
This method will handle clicks on clustered items
publicbooleanonClusterClick(Cluster<Person> cluster) {
// Show a toast with some info when the cluster is clicked.Toast.makeText(getActivity(), cluster.getSize() + " (including " + itemText + ")", Toast.LENGTH_SHORT).show();
returntrue;
}
And this method will handle onClick events if marker is not clustered (has single item)
publicbooleanonClusterItemClick(Person item) {
// Handles events for single markersString text = item.text;
returntrue
}
Post a Comment for "Android Get The Markers That Are Not Clustered"