Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My location button not appearing in view (Google maps SDK, ios)

Here is my mapViewController.m file:

@interface MapViewController()

@property (strong, nonatomic) GMSMapView* mapView;
@property (weak, nonatomic) IBOutlet GMSMapView *subView;

@end

@implementation MapViewController

    - (void) viewDidLoad{
    // Create a GMSCameraPosition that tells the map to display the
    // coordinate -33.86,151.20 at zoom level 6.
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                        longitude:151.20
                                                             zoom:6];

    _mapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera];

    _mapView.myLocationEnabled = YES;

    _mapView.settings.compassButton = YES;
    _mapView.settings.myLocationButton = YES;

    [self.subView addSubview:_mapView];
}

My problem is that the my location button doesn't appear, any help appreciated! :) Please tell me if you need to see more of my project.

like image 889
Janon Avatar asked Dec 05 '25 13:12

Janon


1 Answers

Got the correct answer. This will work even if you added the mapview as a subview. Tested and verified the same upto IOS 9.2

_mapView.settings.myLocationButton = YES
like image 129
Anooj VM Avatar answered Dec 07 '25 03:12

Anooj VM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!