2016-09-29 8 views

答えて

0

これは、あなたが、あなたがthis current locationを非表示にする(設定することにより、すなわち - yourMapView.showsUserLocationfalseに)それを変更するために弱々しい場合、MKMapViewcurrent locationためdefault viewであり、あなたがそのlatlongにカスタムannotationを追加することができ、私は意味青の代わりに表示したいカスタム画像(黒い画像)!

以下デリゲートに見てみましょう

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { 

static NSString* AnnotationIdentifier = @"Annotation"; 
MKPinAnnotationView *pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier]; 

if (!pinView) { 

    MKPinAnnotationView *customPinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] autorelease]; 
    if (annotation == mapView.userLocation){ 
     customPinView.image = [UIImage imageNamed:@"myCarImage.png"]; 
    } 
    else{ 
     customPinView.image = [UIImage imageNamed:@"mySomeOtherImage.png"]; 
    } 
    customPinView.animatesDrop = NO; 
    customPinView.canShowCallout = YES; 
    return customPinView; 

} else { 

    pinView.annotation = annotation; 
} 

return pinView; 
} 

参考:This SO Post!

関連する問題