在GMSMapView出口中显示地图的问题



我正在学习谷歌的教程,一切都很好,只是我不能在GMSMapView出口中显示地图。我该怎么做?

viewDidLoad()中的代码:

 locationManager.delegate = self
        locationManager.requestWhenInUseAuthorization()
        let camera = GMSCameraPosition.cameraWithLatitude(-33.86,
            longitude: 151.20, zoom: 6)
        let mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera)
        mapView.myLocationEnabled = true
        self.view = mapView
        let marker = GMSMarker()
        marker.position = CLLocationCoordinate2DMake(-33.86, 151.20)
        marker.title = "Sydney"
        marker.snippet = "Australia"
        marker.map = mapView

出口申报为:

@IBOutlet weak var googleMapView: GMSMapView!

插座是从UIView接口连接的,该接口的类型已更改为GMSMapView。

感谢的帮助

您在didFinishLaunchingWithOptions函数的appdelegate中有这个吗?

GMSServices.provideAPIKey(googleMapsApiKey)

其中,googleMapsApiKey是您的谷歌ios api密钥

最新更新