Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MKPinAnnotationView image offset?

Does anyone have any idea why images used for a MKPinAnnotationView should be offset slightly (up and to the right) the code I am using is:

pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pinView_ID];
pinView.image = [UIImage imageNamed: @"TEST_Small.png"];
// RedCircleImage = 40px x 40px 72dpi PNG
// GreenDotImage = 2px x 2px 72dpi PNG

alt text

There are no changes to the code just a change in the filename for the image used, one image is the "the two red rings with a black dot in the center" the other is the "small green dot" I have added the thin blue lines in Photoshop to help show where the green dot is.

I have checked the centerOffset property and its correctly set to 0,0

Any ideas would be welcome.

like image 576
fuzzygoat Avatar asked Jan 20 '11 13:01

fuzzygoat


1 Answers

As Dolbz has pointed out, you should use MKAnnotationView instead of MKPinAnnotationView. When you set the image, you can also set a centerOffset that is appropriate for your image. The default centerOffset should work for your images, but if you would display a pin, flag, etc. you would set it differently.

like image 116
omz Avatar answered Sep 24 '22 19:09

omz