choefele/CCHMapClusterController

Mistake in CCHMapClusterController

Closed this issue · 2 comments

Hi,

you have a mistake in CCHMapClusterController.m in - (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated...

You have to change
if (hasZoomed) {
[self deselectAllAnnotations];
}

into

//if (hasZoomed) {
    [self deselectAllAnnotations];
//}

If you don't do so and zoom in to a cluster leaf (which is actually an annotation added by using addAnnotations), click at the AnnotationView, the callout appears, then you move the Map to a different location (not zooming) and the AnnotationView gets re-used, then you have callout opened at every reused AnnotationView.
if (clusterAnnotation.isCluster) {...
}else{
// cluster ist leaf, sprich es hat nur noch ein objekt in annotations also können wir es mit Hilfe von anyObject kriegen
PreisInfo *preisInfo = clusterAnnotation.annotations.anyObject;
NSNumber *preis = [currentDefaultsHelper getCurrentDefaultsPrice:preisInfo];

        // Die Annotation View für einzelne Tankstellen
        MKPinAnnotationView *pinAnnotation;
        NSString *annotationViewName = @"mapTanke";
        // Error happens here: you reuse AnnotatioView with opened Callout
        pinAnnotation = (MKPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:annotationViewName];
        if(pinAnnotation == nil){
            pinAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:preisInfo reuseIdentifier:annotationViewName];
        }

Greetings
John

Hi John,

I'm not sure I understand exactly how to reproduce the issue. Would you mind providing a sample project with step-by-step instructions on how to reproduce it?

Removing if (hasZoomed) will have the undesirable side effect of always deselecting the annotations even when you pan. There are various issues (e.g. #65) related to deselecting annotations – I'm actually thinking to remove any call to deselectAllAnnotations and app developers have to decide themselves when to deselect the annotations.

-Claus

I assume you have solved your problem because I haven't heard back for a while. Please reopen if needed.