How can I block user interaction with the my current location pin? I have problem like this: I have many pins on my map and if they are close and they are around "my current location" pin, that pin takes the click event I wan to block it. i don't want the bubble "Current Location" to be shown. I know it is something with *pinView.canShowCallout = NO; but how do I know what pin is my location?? Thanks
Asked
Active
Viewed 499 times
2 Answers
0
this should give you what you need..
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view{
if ([annotation isKindOfClass:[MKUserLocation class]]) {
view.canShowCallout=NO;
}
}
Let me know if it works.. :)

Ankit Srivastava
- 12,347
- 11
- 63
- 115
0
this doesn't work because you need to select it at least one to work it out, but thanks anyway it helped very much for the search starting point :) I did it with this code:
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
for(int i = 0; i< [views count]; i++)
{
if([[[[views objectAtIndex:i] class] description] isEqualToString:@"MKUserLocationView"])
{
((MKAnnotationView*)[views objectAtIndex:i]).canShowCallout = NO;
}
}
}
you must find the view and them apply it.
also you need to put this:
if ([annotation isKindOfClass:[MKUserLocation class]]) {
[mapView viewForAnnotation:annotation].canShowCallout = NO;
return [mapView viewForAnnotation:annotation];
}
in :- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation

Toshe
- 459
- 1
- 6
- 20
-
I would try to limit it to the mapView:viewForAnnotation method as I'm pretty sure the for loop is superfluous. – Cyril Godefroy Apr 09 '12 at 10:20
-
in viewForAnnotation you're supposed to return nil, so you don't really have an object to do this on there. – Ivo Jansch May 21 '14 at 08:12