1

I need to see user location using a custom annotation, and then I add more annotaions of various types in the vicinity of the user (eg monuments, restaurants cinema ...). If I write the code in this method displays the user's location.

- (void) locationManager:(CLLocationManager *) manager
 didUpdateToLocation:(CLLocation *) newLocation
        fromLocation:(CLLocation *) oldLocation {

    //......

   MyAnnotation *annotationUser = [[MyAnnotation alloc]initWithCoordinates:self.coordinate  title:@"YOU ARE HERE" subTitle:@"via Giorgio Giulini 2"];

   [self.mapView addAnnotation:self.annotationUser];


}

If I add the method

 - (MKAnnotationView *)mapView:(MKMapView *)mapview viewForAnnotation:(id <MKAnnotation>)annotation
 {
      //.....
  }

to create the other annotations, the user's location is no longer displayed. Why?

Ortensia C.
  • 4,666
  • 11
  • 43
  • 70
  • You're adding a new annotation every time the location manger gets anew user location? That doesn't seem right. If you're happy with just the blue dot for the user you can drop the `annotationUser` stuff and just set `mapView.showsUserLocation = YES;` – Craig Nov 06 '12 at 18:08

1 Answers1

2

try this

    - (MKAnnotationView *)mapView:(MKMapView *)mapview viewForAnnotation:(id <MKAnnotation>)annotation
 {
    if ([annotation isKindOfClass:[MyAnnotation class]]) {

        return nil;

    } else {

        //.....

    }


  }
jcesarmobile
  • 51,328
  • 11
  • 132
  • 176