I am able to load a big list of location onto my MapKit and display them all with a custom Pin image and annotation.
The issue i'm having is that I currently have all annotations displaying the same Title, Subtitle, and pinImage.
How do I make it so that I can set each annotation with its own Title and different Pin image? I'm having a hard time trying to identify what annotation is being setup via mapView:viewForAnnotation.
- (NSString *)subtitle{
return @"This is the annotation subtitle.";
}
- (NSString *)title{
return @"Annotations Title";
}
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
if (annotation == mapView.userLocation) {
return nil;
}
MKAnnotationView *annView=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
UIImage *pinImage = [UIImage imageNamed:@"mapPin.png"];
annView.image = pinImage;
return annView;
}