Reputation: 3797
I added a view in the storyboard, then set the view to GMSMapView. But now the location button and compass in the map is missing. When I add the map programmatically using the instructions from https://developers.google.com/maps/documentation/ios/start#adding_the_google_maps_sdk_for_ios_to_your_project, the controls of the map appear.
.h class
@interface MapController : UIViewController{
IBOutlet GMSMapView *mapView_;
}
.m class
- (void)viewDidLoad {
[super viewDidLoad];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:mapView_.myLocation.coordinate.latitude longitude:mapView_.myLocation.coordinate.longitude zoom:1];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
mapView_.settings.myLocationButton = YES;
mapView_.settings.compassButton = YES;
}
Upvotes: 0
Views: 751
Reputation: 893
I use these lines of code in viewDidLoad and it works properly:
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.delegate = self;
self.view = mapView_;
mapView_.settings.myLocationButton = YES;
mapView_.settings.compassButton = YES;
Also i don't use an outlet.It doesn't needed.
Upvotes: 0
Reputation: 366
This works fine for me...
mapView_ = [GMSMapView mapWithFrame:self.mapView.bounds
camera:camera];
self.mapView is the view in storyboard. Create IBOutlet for that view
Upvotes: 2