I am using custom call out (title and subtitle)for Current location icon. I tried following to disable default annotation but it does not work.
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
NSLog(@"viewForAnnotation");
if ([annotation isKindOfClass:[MKUserLocation class]])
{
MKAnnotationView *userLocationView = [mapView viewForAnnotation:annotation];
userLocationView.canShowCallout = NO;
NSLog(@"[annotation isKindOfClass:[MKUserLocation class]");
return nil;
}
}
Only way it works is
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)ann
{
if([ann.annotation isKindOfClass:[MKUserLocation class]] )
{
[mymap deselectAnnotation:ann.annotation animated:NO];
}
}
But it lags sometimes. Is there other way do disable default callout view for current location annotation? Any help will be appreciated.
To get this done one need to get reference of current location
MKAnnotationView. One can get this reference anywhere but it is better to get it as soon as user location is determined.Or use following method
and if want to change in canShowCallout property in runtime then one can use following