
Untitled
By: a guest on
Aug 6th, 2012 | syntax:
Objective C | size: 0.94 KB | hits: 56 | expires: Never
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation {
// if it's the user location, just return nil.
if ([annotation isKindOfClass:[MKUserLocation class]]){
return nil;
}
MKAnnotationView *pinView = [map viewForAnnotation:annotation];
PersonPin *pin = (PersonPin*)annotation;
if (!pinView || pin.needsDisplay) {
MKAnnotationView *annotationView =
[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annotationIdentifier];
UIImage *image;
image = [UIImage imageNamed:[pin getPinImage]];
UIImage *resizedImage = [pin sizePinToFitMap:image bounds:self.view.bounds];
annotationView.image = resizedImage;
annotationView.canShowCallout = YES;
annotationView.annotation = annotation;
annotationView.opaque = NO;
return annotationView;
} else {
pinView.annotation = annotation;
}
return pinView;
}