2

I would like to set a custom image instead of the normal pin on a Map. I also want it to be able to be opened and add the drop annimation for each one.

Any suggestion?

EDIT: Here is all I have

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(ActivityAnnotation *)annotation
{
    static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
    MKPinAnnotationView* pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
    pinView.animatesDrop=YES;
    pinView.canShowCallout=YES;
    UIImage *image = [UIImage imageNamed:@"Map_Pin"];
    pinView.image = image;
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    imageView.frame = CGRectMake(-2.5,6,27,30);
    [pinView addSubview:imageView];
    UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    rightButton.tag = [activities indexOfObject:annotation.activity];
    [rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
    pinView.rightCalloutAccessoryView = rightButton;

    return pinView;
}

Everything works fine, but the original pin keeps getting displayed behind my default image. How can I erase it?

sergiocg90
  • 489
  • 2
  • 11
  • 24

1 Answers1

6

Try not using MKPinAnnotationView, but instead using MKAnnotationView. The MKPinAnnotationView shows a pins by default and only allows you to customize the color (if I'm not mistaken). The MKAnnotationView allows for custom pin images.

Chris Truman
  • 913
  • 1
  • 7
  • 25