Swift:我的Google地图视图没有显示

Jon*_*ant 1 uiview ios google-maps-sdk-ios

我正在尝试首次将Google Maps SDK实施到我的iOS应用中.遵循Google的教程后,Google地图仍未显示在我的视图中.

这是我的AppDelegate代码:

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

这是我的View Controller中的代码,直接来自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
Run Code Online (Sandbox Code Playgroud)

但是,视图仍然没有显示出来.我检查了我的IBOutlet视图 - mapsView - 这是正确的.这是我的故事板的图像:在此输入图像描述

概述的空视图是我的地图视图.但这是我的应用程序在运行时的样子:在此输入图像描述

Jon*_*ant 11

将视图的自定义类更改为Storyboard中的GMSMapView而不是UIView.

  • 这个细节很简单,容易忘记 (2认同)