Tapping the pulsating blue circle representing the userLocation brings up a "Current Location" callout. Is there a way to suppress that?
Asked
Active
Viewed 6,098 times
7 Answers
18
There's a property on the annotation view you can change, once the user location has been updated:
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
MKAnnotationView *userLocationView = [mapView viewForAnnotation:userLocation];
userLocationView.canShowCallout = NO;
}
-
Sometimes location cannot be determined and MKUserLocation turns gray. Callout is still being displayed in that case. This answer is not correct. – pronebird Jan 09 '17 at 12:29
-
do this alone doesn't work for me on iOS 10. handling in `viewForAnnotation` works. – Nicholas Ng Jul 13 '17 at 21:38
16
You can set the title
to blank to suppress the callout:
mapView.userLocation.title = @"";
Edit:
A more reliable way might be to blank the title in the didUpdateUserLocation
delegate method:
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
userLocation.title = @"";
}
or in viewForAnnotation
:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>) annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]])
{
((MKUserLocation *)annotation).title = @"";
return nil;
}
...
}
Setting the title in the delegate methods lets you be certain you have a real userLocation instance to work with.
-
Thanks! I knew i could change the title and subtitle but didn't know setting the title to a blank string would suppress it. – charudatta Nov 30 '11 at 23:24
-
-
@Anna been fiddling but haven't had success - any thoughts as to how to suppress the default callout bubble entirely (as above, and yes, @jowie answer probably better) without blocking `mapView:didSelectedAnnotationView:` to be called? – Will Von Ullrich May 03 '17 at 16:32
6
Swift 4
// MARK: - MKMapViewDelegate
func mapViewDidFinishLoadingMap(_ mapView: MKMapView) {
if let userLocationView = mapView.view(for: mapView.userLocation) {
userLocationView.canShowCallout = false
}
}

Włodzimierz Woźniak
- 3,106
- 1
- 26
- 23
-
mapView.view(for: mapView.userLocation) seems like the most elegant option indeed! You can also leverage this in the ```mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation)``` callback to group it together with all other annotation views – thiezn Sep 14 '19 at 06:34
2
Swift 4 - Xcode 9.2 - iOS 11.2
// MARK: - MKMapViewDelegate
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
if let userLocation = annotation as? MKUserLocation {
userLocation.title = ""
return nil
}
// ...
}

juliancadi
- 987
- 1
- 8
- 23
1
I have two ways to help you:
suppress in the mapViewDidFinishLoadingMap
func mapViewDidFinishLoadingMap(_ mapView: MKMapView) { mapView.showsUserLocation = true //suppress the title mapView.userLocation.title = "My Location" //suppress other params
}
suppress in the didUpdate
func mapView(_ mapView: MKMapView, didUpdate userLocation: MKUserLocation) { //suppress the title mapView.userLocation.title = "My Location" //suppress other params }

coders
- 2,287
- 1
- 12
- 20
1
SWIFT Version
We need to set the user MKAnnotationView
property canShowCallout
to false when mapView
adds the user MKAnnotationView
func mapView(_ mapView: MKMapView, didAdd views: [MKAnnotationView]) {
for view in views {
if view.annotation is MKUserLocation {
view.canShowCallout = false
}
}
}

ashish
- 351
- 3
- 7
0
Hey there is an updated easy solution
Swift:
mapView.userLocation.title = "";
.Net for iOS (Xamarin.iOS)
NativeMap.UserLocation.Title = "";
Regards ;)

G Clovs
- 2,442
- 3
- 19
- 24
-
Please don't post identical answers to multiple questions. Instead, tailor the answer to the question asked. If the questions are exact duplicates of each other, please vote/flag to close instead. – Yunnosch Aug 25 '20 at 19:30