Hide MKUserLocation when MKMapView shows UserLocation == YES

After setting mapView.showsUserLocation to true, can I get location updates without showing the MKUserLocation bubble? Returning nil to mapView:viewForAnnotation: just shows the bubble, and when you return any other kind of annotation, an annotation that I don't want is displayed.

+6
source share
2 answers

You can hide the view of the user's location in the didAddAnnotationViews delegate didAddAnnotationViews :

 -(void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views { MKAnnotationView *ulv = [mapView viewForAnnotation:mapView.userLocation]; ulv.hidden = YES; } 
+25
source

Swift 3:

 func mapView(_ mapView: MKMapView, didAdd views: [MKAnnotationView]) { if let userLocation = mapView.view(for: mapView.userLocation) { userLocation.isHidden = true } } 
0
source

Source: https://habr.com/ru/post/910756/


All Articles