After setting mapView.showsUserLocation
to true, is it possible to receive location updates without showing the MKUserLocation bubble? Returning nil in mapView:viewForAnnotation:
simply shows the bubble, and returning any other kind of annotation shows an annotation, which I don't want.
Asked
Active
Viewed 4,519 times
8

eric.mitchell
- 8,817
- 12
- 54
- 92
2 Answers
26
You can hide the user location's view in the didAddAnnotationViews
delegate method:
-(void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
MKAnnotationView *ulv = [mapView viewForAnnotation:mapView.userLocation];
ulv.hidden = YES;
}
-
1Wow, perfect. I didn't realize you could manipulate MKAnnotationViews this way. Though I suppose it makes sense, as they are just UI objects. Thank you! – eric.mitchell Mar 15 '12 at 03:57
-
@Elgert, This method should be in the class that implements the MKMapView delegate (usually the one that contains the map view). Make sure the map view's delegate property is set. – Jul 07 '14 at 14:28
-
i did what you said and still the blue marker appears :( – Elgert Jul 07 '14 at 15:00
-
@Elgert, Please ask a new question with details and the code you are using. – Jul 07 '14 at 15:01
3
Swift 3:
func mapView(_ mapView: MKMapView, didAdd views: [MKAnnotationView]) {
if let userLocation = mapView.view(for: mapView.userLocation) {
userLocation.isHidden = true
}
}

nsmeme
- 221
- 4
- 1