0

So i am using xcode 6.2 and i am starting with making apps. but i have a question: whenever i drag something in my storyboard like a navigation bar the map overlays it, it simply won't show up, please help. Here is my code

#import "ViewController.h"

@interface ViewController () {
    GMSMapView *mapView;
}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:43.642510 longitude:-79.387038 zoom:12 bearing:0 viewingAngle:0];
    mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
    mapView.myLocationEnabled = YES;
    self.view = mapView;


    GMSMarker *marker = [[GMSMarker alloc] init];
    marker.position = CLLocationCoordinate2DMake(43.642510, -79.387038);
    marker.title = @"CN-Tower";
    marker.snippet = @"A beautifull tower";
    marker.map = mapView;
    marker.opacity = 0.7;
}

Thanks anyway, JP

1 Answers1

0

When you do self.view = mapView you're setting the root view of the view controller to the map - and so the map covers everything, replacing whatever you designed in your storyboard.

What you need to do is add the map as a subview of the root view, eg here's a few ways to do it:

Using the Google Maps SDK in views other than the main view

Google Maps iOS SDK - Add UIView/UIButton over a GMSMapView

Google Maps iOS SDK and storyboards

Community
  • 1
  • 1
Saxon Druce
  • 17,406
  • 5
  • 50
  • 71