我用以下代码扩展了MapKit绘制自定义注释图像的能力:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
NSLog(@"Drawing a cloud on the map");
MKAnnotationView *view;
if(annotation != mapView.userLocation){
view=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"parkingloc"];
view.image=[UIImage imageNamed:@"placemarkCloud.png"];
[view setCanShowCallout:YES];
[view setRightCalloutAccessoryView:[UIButton buttonWithType:UIButtonTypeDetailDisclosure]];
}
else{
view=
}
return view;
}我的问题是,为了保留iPhone内置的蓝点,我应该做什么view = to。您可以看到,我删除了为点绘制的自定义图像,但我不知道如何将其显示为默认图像。
发布于 2010-09-11 11:32:40
不要在其他地方放任何东西。我执行以下检查。我认为这是从Apple示例代码派生而来的。
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
if ([annotation isKindOfClass:[MKUserLocation class]]) {
//Don't trample the user location annotation (pulsing blue dot).
return nil;
}
//Continue on to your regular code here.https://stackoverflow.com/questions/3686515
复制相似问题