2012-12-12 6 views
8

は、私は、カスタムMKAnnoationViewを作成:ポジショニングカスタムMKAnnotationView

- (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; 
} 

私は多かれ少なかれ、適切な場所での位置付けではなく、かなりたい画像を取得します。私はマップに標準ピン視点座標のように私の注釈マップにポイントに涙滴の底点は、座標たい

enter image description here

:私のイメージはこのようになります。どうすればこれを達成できますか?現在、私のイメージはマップの座標の中心にあるように見えます。

答えて

13

デフォルトでは、注釈ビューの中心は注釈座標に配置されます。表示位置を調整するには、centerOffsetプロパティを設定します。

annotationView.centerOffset = CGPointMake(0.0f, -annotationViewHeight/2); 
+0

この場合、ビューの中心が正確な座標位置に揃えられます。ピンの基部は正確さのために座標にあるべきです。 – carbonr

関連する問題