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.
Hide MKUserLocation when MKMapView showsUserLocation == YES
Asked Answered
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;
}
Wow, 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! –
Rafael
@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. –
Sedentary
i did what you said and still the blue marker appears :( –
Varga
@Elgert, Please ask a new question with details and the code you are using. –
Sedentary
Swift 3:
func mapView(_ mapView: MKMapView, didAdd views: [MKAnnotationView]) {
if let userLocation = mapView.view(for: mapView.userLocation) {
userLocation.isHidden = true
}
}
© 2022 - 2024 — McMap. All rights reserved.