我正在关注Google的教程,除了我无法在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。
感谢您的帮助
答案 0 :(得分:0)
你在didFinishLaunchingWithOptions函数的appdelegate中有这个吗?
GMSServices.provideAPIKey(googleMapsApiKey)
googleMapsApiKey是你的google ios api密钥