I create a custom MKAnnoationView as follows:
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
MKAnnotationView* customPinView = [[MKAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
UIImage *pinImage = [PowerPlantAnnotation getAnnotationImageForEnergySource:((PowerPlantAnnotation*)annotation).energySource];
customPinView.image = pinImage;
return customPinView;
}
I get the image that I want positioned more or less in the right spot, but not quite. My image looks like this:
I want the bottom point of the tear drop to point to my annotation map coordinate, like the standard pin view points to the map coordinate. How can I accomplish this? Currently it looks a bit more like my image is centered on the map coordinate.
By default annotation view center is placed at the annotation coordinate. To adjust view position set its centerOffset property:
annotationView.centerOffset = CGPointMake(0.0f, -annotationViewHeight/2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With