我有一个MKAnnotation与自定义图钉图像.但是,引脚(MKAnnotationView)使图像相对于指定的坐标居中.我想将坐标点设置在图像的底部中心,而不是中心.
我试过用了annView.centerOffset = CGPointMake(-12, -28);.但问题是centerOffset与地图缩放级别无关.
可以在JS API和Android中执行此操作.有没有可能在objective-c中这样做?
..fredrik
我使用自定义图像进行mapkit注释.但是我在使用自定义图像时遇到的主要问题是,当缩小时,注释不在地图上的正确位置,并且只有在我一直向下放大时,它才会显示注释点在正确的位置.似乎当我使用常规引脚MKPinAnnotationView时,它正常工作,因为引脚位于正确的位置放大或缩小,提前感谢任何可以提供帮助的人.
我使用的代码如下:
- (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
NSLog(@"welcome into the map view annotation");
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
MKAnnotationView *pprMapNote = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pprMapNote"];
pprMapNote.image = [UIImage imageNamed:[NSString stringWithFormat:@"GPS_note.png"]];
pprMapNote.canShowCallout = YES;
pprMapNote.centerOffset = CGPointMake(-21,-60);
pprMapNote.calloutOffset = CGPointMake(0, 0);
//[pprMapNote addSubview:pprMapNoteImg];
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:self
action:@selector(showDetail)
forControlEvents:UIControlEventTouchUpInside];
pprMapNote.rightCalloutAccessoryView = rightButton;
//remember to write in conditional for the different icons that should be loaded based on location
UIImageView *pprNoteLocIcon = [[UIImageView alloc] …Run Code Online (Sandbox Code Playgroud)