简体   繁体   English

Swift:我的Google Maps View没有显示

[英]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. 我正在尝试第一次在我的iOS应用中实现Google Maps SDK。 After following Google's tutorial, Google Maps still does not show up in my view. 遵循Google的教程后,我认为Google Maps仍然没有显示。

Here is my AppDelegate code: 这是我的AppDelegate代码:

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: 这是我的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

However, the view still doesn't show up. 但是,该视图仍未显示。 I checked my IBOutlet for my view - mapsView - and it is correct. 我检查了IBOutlet的视图-mapsView-正确。 Here is an image of my storyboard: 这是我的情节提要的图像: 在此处输入图片说明

Where the empty view outlined is my maps view. 概述的空视图是我的地图视图。 But here it what my app looks like when it runs: 但是在这里,我的应用程序运行时的样子: 在此处输入图片说明

将视图的自定义类更改为情节提要中的GMSMapView而不是UIView。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM