Search code examples
iosgoogle-mapsgoogle-maps-sdk-ios

How to implement iOS Google Maps SDK


I just have a question and can't seem to find it anywhere.

I"m new to iOS development and trying to use Google Maps inside my application.

I went thru the example they give you here.

    #import "DemoViewController.h"
#import <GoogleMaps/GoogleMaps.h>

@implementation DemoViewController {
  GMSMapView *mapView_;
}

- (void)loadView {
  GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:1.285
                                                          longitude:103.848
                                                               zoom:12];
  mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
  self.view = mapView_;
}

@end

But as you can see the they set self.view = mapView_; and the UIView class doesn't have a view function.

I want the map to be inside a UIView I have that is inside another ViewController

Did I lose you yet? Either ways here is a picture. enter image description here

So inside of the view (or whitespace) I want the map to load.

Thanks guys for the help.


Solution

  • I found a solution that works for me if anyone needs to do something similar.

    I just used a container view and then made separate UIViewController class (that has the google maps sdk code add a map section) and then hooked it up to my main ViewController by using [self.view addSubview:googleMapsView]; googleMapsView being my container view that I connected to the main ViewController.