开发者

Extended mapView:viewForAnnotation Now No Blue Dot

开发者 https://www.devze.com 2023-01-16 04:28 出处:网络
I have extended MapKit\'s ability to draw custom annotation images with the following code: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{

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:@"place开发者_如何学CmarkCloud.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.


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.
0

精彩评论

暂无评论...
验证码 换一张
取 消