Jonathan Allen Grant Jonathan Allen Grant - 1 month ago 27
iOS Question

Swift: My Google Maps View isn't showing up

I am trying to implement Google Maps SDK into my iOS app for the first time. After following Google's tutorial, Google Maps still does not show up in my view.

Here is my AppDelegate code:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
GMSServices.provideAPIKey("\(myAPIKey)")
return true
}


and here is the code in my View Controller, straight from Google:

var camera = GMSCameraPosition.cameraWithLatitude(-33.86,
longitude: 151.20, zoom: 6)
var mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera)
mapView.myLocationEnabled = true
mapsView = mapView

var marker = GMSMarker()
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20)
marker.title = "Sydney"
marker.snippet = "Australia"
marker.map = mapView


However, the view still doesn't show up. I checked my IBOutlet for my view - mapsView - and it is correct. Here is an image of my storyboard:enter image description here

Where the empty view outlined is my maps view. But here it what my app looks like when it runs: enter image description here

Answer

I found my answer:

Change the custom class of the view to a GMSMapView in the Storyboard instead of a UIView.