Disable MKmapkit mapView userLocation annotationView
Asked Answered
I

1

6

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!

Intracutaneous answered 8/10, 2012 at 22:47 Comment(5)
You can't do self.mapView.userLocation.enabled = NO?Veii
If you don't mind making your own annotation view, you can override the view that gets used in -mapView:viewForAnnotation:. A lot of work though!Fipple
@Nathan Villaescusa, I though the same thing. Unfortunately trying 'self.mapView.userLocation.enabled = NO' results in an error: Property 'enabled' not found on object of type 'MKUserLocation'Intracutaneous
@0xSina Unfortunately I want the annotation, the blue dot to be visible, just not selectable. Setting the 'annotation.hidden = YES' for the userLocation results in the entire annotation not being visible. Thanks!Intracutaneous
@tc Overriding the annotation with a custom annotation is an option. However, I have not found a way to recreate the blue circle location accuracy pulse around the built in blue dot annotation. But this would be the fall back solution. Thanks!Intracutaneous
E
8

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

Encephalic answered 9/10, 2012 at 1:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.