tags:

views:

98

answers:

2

I have extended MapKit's ability to draw custom annotation images with the following code:

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

}

My question is what should I make view = to in order to retain the iPhone's built in blue dot. You can see that I eliminate my custom image being drawn for the dot, but I don't know how to make it show as default.

+2  A: 

Don't put anything in the else. I do the following check. I think this is derived from Apple sample code.

- (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.
Nick
A: 

I figured that out shortly after posting. Thanks for your help!

wasabi