views:

25

answers:

0

I am using

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

to draw my own image for a custom pin. I would like to use a different image for different pins. I was wondering how I could differentiate which pin was calling this function.

EDIT: annView.annotation.title did the trick.

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

    MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"MyPin"];
    annView.canShowCallout = YES;

    annView.calloutOffset = CGPointMake(-5, 5);

    if ([annView.annotation.title isEqualToString:myLocation]) {
        UIImage *pinImage = [UIImage imageNamed:@"myLocationImage.png"];
        [annView setImage:pinImage];
    } else {
        UIImage *pinImage = [UIImage imageNamed:@"resImage.png"];
        [annView setImage:pinImage];
    }

    return annView;
}