0

thisコードを使用してMKPointAnnotationに画像を追加しています。ユーザロケーションイメージを変更せずにMKPointAnnotationに画像を追加

- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation 
{ 
    static NSString *SFAnnotationIdentifier = @"SFAnnotationIdentifier"; 
    MKPinAnnotationView *pinView = 
    (MKPinAnnotationView *)[_routeMap dequeueReusableAnnotationViewWithIdentifier:SFAnnotationIdentifier]; 
    if (!pinView) 
    { 
     MKAnnotationView *annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation 
                     reuseIdentifier:SFAnnotationIdentifier]; 
     UIImage *flagImage = [UIImage imageNamed:@"BikeIconMap"]; 
     // You may need to resize the image here. 
     annotationView.image = flagImage; 
     return annotationView; 
    } 
    else 
    { 
     pinView.annotation = annotation; 
    } 
    return pinView; 
} 

ただし、ユーザーの場所のカスタム画像も表示しています。ユーザーの場所の円形波アニメーションも消えています。

enter image description hereenter image description here

ユーザの位置の画像やアニメーションを変更することなく、MKPointAnnotationに画像を追加する方法はありますか?

答えて

1

viewForAnnotationにこのコードを追加します。MKMapViewDelegate

の方法
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation 
{ 
    if (annotation == mapView.userLocation) return nil; 
関連する問題