hulab / ClusterKit

An iOS map clustering framework targeting MapKit, Google Maps and Mapbox.
MIT License
512 stars 86 forks source link

Make annotations property public for CKCluster #8

Closed stasivanov closed 7 years ago

stasivanov commented 7 years ago

Sometimes it is very useful to get annotations that are combined under specific cluster to have more flexibility around annotationView text, and not just show count of objects there. Please make it public

maxep commented 7 years ago

You can have access to a cluster's annotations :

id<CKAnnotation> annotation = cluster.firstAnnotation;
id<CKAnnotation> annotation = cluster.lastAnnotation;
id<CKAnnotation> annotation = cluster[3];

for(id<CKAnnotation> annotation in cluster) {
  ...
}
stasivanov commented 7 years ago

Thanks. But sometimes there is a specific case, when I need just cluster.annotations. It would be better to make it read only.

Also, I cannot make that "for in loop" works in Swift.

stasivanov commented 7 years ago

For in loop works with adding extension

extension CKCluster: Sequence { public func makeIterator() -> NSFastEnumerationIterator { return NSFastEnumerationIterator(self) } }