2016-09-29 282 views

回答

0

這是default viewMKMapViewcurrent location,如果你婉去改變它,那麼你應該隱藏this current location(通過設置IE瀏覽器 - yourMapView.showsUserLocationfalse),你可以添加自定義annotationlatlong,我的意思自定義圖像(黑色圖像),你想顯示,而不是藍色!

採取下面委託一看,

- (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!

相關問題