iOSのマップにカスタムマーカーを配置していますが、ユーザーがピンチしてズームインおよびズームアウトすると、マーカーが本来の位置に固定されないという問題があります。マーカーを追加するコードは次のとおりです...
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
MarkerVO *thisMarker = (MarkerVO*)annotation;
MKAnnotationView *pin = (MKAnnotationView *) [map dequeueReusableAnnotationViewWithIdentifier:[thisMarker commaSeparatedCoordinate]];
if (!pin) {
pin = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:[thisMarker commaSeparatedCoordinate]] autorelease];
[pin setImage:[UIImage imageNamed:@"pin_tick.png"]];
[pin setCenterOffset:CGPointMake(0, -23)];
[pin setCanShowCallout:YES];
}
return pin;
}
そうです、目盛りマーカーは「OK」と表示されますが、ズームでは動き回るだけです。たとえば、ズームを閉じるとその場で正しい可能性がありますが、ズームアウトすると海に出てしまいます。なぜこれが起こっているのかがわかりますが、setCenterOffset行がなくてもまだ起こっています。
どんなアイデアでも素晴らしいでしょう。