Search code examples
iosmapkitmkannotationmkannotationview

Current location annotation default look?


I have the following code:

- (MKAnnotationView *) mapView:(MKMapView *) mapView viewForAnnotation:(id ) annotation {

    MKPinAnnotationView *customAnnotationView=[[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil] autorelease];

    customAnnotationView.pinColor = MKPinAnnotationColorRed;
    customAnnotationView.animatesDrop = NO;
    customAnnotationView.canShowCallout = YES;

    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    [rightButton addTarget:self action:@selector(annotationViewClick:) forControlEvents:UIControlEventTouchUpInside];

    customAnnotationView.rightCalloutAccessoryView = rightButton;

    return customAnnotationView;
}

This method changes every annotation on the mapview, including the current location blue circle annotation. I want to change only my custom annotations and leave the current location annotation alone.

How can I do this?


Solution

  • Return nil if the annotation is the userLocation annotation

    if(annotation == mapView.userLocation){
        return nil;
    }