Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hide blue dot while retrieving google map current location in IOS

I am trying to add the default button to return to current Location within google map. I added the button using

self.mapView.myLocationButton = YES 

But not able to hide the blue dot which is not required in my case.

If i set

self.mapView.myLocationEnabled = NO

It would remove the functionality to return back to current Location on pressing the current Location button.

Following is the code i've implemented

 - (void)viewDidLoad
 {
     [super viewDidLoad];
     // Do any additional setup after loading the view.

     self.mapView.delegate = self;

     self.mapView.settings.myLocationButton = YES;
     self.mapView.myLocationEnabled = YES;

 }
like image 401
Arjun K P Avatar asked Mar 27 '26 08:03

Arjun K P


1 Answers

You can simply add the annotation view:

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

In this way the map will still receive user's location updates but the blue dot is hidden. Remember that since this is a delegate method, you should correctly set the delegate.

like image 76
Antonio E. Avatar answered Mar 30 '26 01:03

Antonio E.