How to get all elements from a cluster of a cluster of Google Maps in iOS

In the Android version of the Google Maps cluster manager, you can get a collection of markers (see Google Maps Utility: how to get all markers from ClusterManager <?>? ). I tried to do the same in iOS, but it does not work. The algoritm class does not expand an array of elements.

Is there any other way to get items? Or I have to do one of the following:

  • Output an array of elements by editing the algorithm class.
  • Sublass is an algorithm class and overwrite methods addItem, clearItemsetc., so I can save a shadow copy of the items array.
  • Keep the shadow copy differently.
+5
source share
1 answer

Logically, this is an algorithm that combines all the elements in a cluster. But I get an error when calling the elements according to the scale value.

let clusters = clusterManager.algorithm.clusters(atZoom: 21.0 //self.googleMap.maxZoom)
for c in clusters {

    for i in c.items {

        if let m = i as? POIItem {
            //some code
        }
    }
}
0
source

Source: https://habr.com/ru/post/1653662/


All Articles