Question

I have a mapView with annotationViews and the userLocation blue dot.

I am using the following code to get the blue dot:

[self.mapView setShowsUserLocation:YES];

The annotationViews are selectable and have callouts.

However if an annotationView is close to the user's location sometimes the blue dot steals the touch.

I can set an annotationView.enabled = NO; and it will show the annotationView but it will not steal a touch from a close by annotationView.

I would like to set the user location blue dot annotationView to enabled=NO, so it does not steal the touch of close by annotationViews.

I can set the title of the blue dot with:

self.mapView.userLocation.title = @"title here..."

But I cannot disable the blue dot.

Thanks!

Was it helpful?

Solution

You can set enabled on the user location's MKAnnotationView by getting a reference to it in the didAddAnnotationViews delegate method (so you can be sure the view is ready):

-(void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
    MKAnnotationView *ulv = [mapView viewForAnnotation:mapView.userLocation];
    ulv.enabled = NO;
}

(There is no enabled property on the userLocation model object -- it's a property of the view.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top