Swift:我的谷歌地图视图没有显示出来

时间:2015-07-17 21:12:47

标签: ios uiview 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
}

以下是我的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

然而,该观点仍然没有显示出来。我检查了我的IBOutlet视图 - mapsView - 这是正确的。这是我的故事板的图像:enter image description here

概述的空视图是我的地图视图。但这是我的应用程序在运行时的样子:enter image description here

1 个答案:

答案 0 :(得分:11)

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