Reputation: 4716
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?
Upvotes: 1
Views: 125
Reputation: 53351
try this
- (MKAnnotationView *)mapView:(MKMapView *)mapview viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MyAnnotation class]]) {
return nil;
} else {
//.....
}
}
Upvotes: 2