choefele/CCHMapClusterController

Not seeing any individual (non-clustered) annotations in mapView:viewForAnnotation:

Closed this issue · 2 comments

I'm calling

  self.mapClusterController = [[CCHMapClusterController alloc] initWithMapView:self.mapView];
  [self.mapClusterController addAnnotations:annotations withCompletionHandler:NULL];

as directed, and my method

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
    MKAnnotationView *annotationView;

    if ([annotation isKindOfClass:CCHMapClusterAnnotation.class]) {
        ...
        annotationView = clusterAnnotationView;
    }

    return annotationView;
}

seems coded correctly. However, annotation.isCluster is always TRUE, and annotation.count is always 2 or more.

I know I have some individual annotations that should not be clustered, and would like to draw an MKAnnotationView with a custom image for each one. I was expecting these to be passed into this method as well so I can choose to draw a custom cluster view (if isCluster) or a custom non-cluster view if it's an individual annotation.

In any case I am not receiving any clusters with a group size of 1.

I also tried setting minUniqueLocationsForClustering to 4, but it seems to have no effect -- I keep getting cluster sizes of 2 or more. I am setting this property on the cluster controller after allocating it.

Any suggestions?

Never mind -- I realized that my test data is duplicating locations (hence cluster size of 2!)
Regarding the other issue -- I see that there are more clusters when I lower minUniqueLocationsForClustering, but that every one of them still reports isCluster=TRUE. So maybe that's a doc issue -- I was expecting clusters below this threshold to report FALSE.

Great - glad you found a solution