2016-12-15 49 views
0

我嘗試使用Swift和Xcode 8.2的iOS版Google地圖SDK。Google地圖不會顯示xcode8.2的新版本

我已經設置API密鑰正確。

我使用Google Map SDK網站示例代碼。

let camera = GMSCameraPosition.cameraWithLatitude(-33.86, 
                 longitude: 151.20, zoom: 6) 
    let mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera) 
    mapView.myLocationEnabled = true 
    myView = mapView 

它會顯示錯誤:

'cameraWithLatitude(_:經度:變焦:)' 已更名爲 '相機(withLatitude:經度:變焦:)'

迅速:84:47: 'CGRectZero' 處於夫特不可用

迅速:85:17: 'myLocationEnabled' 已被重命名爲 'isMyLocationEnabled'

所以我改變了下面這樣的:

let camera = GMSCameraPosition.camera(withLatitude: -33.86, 
                 longitude: 151.20, zoom: 6) 
    let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera) 
    myView.isMyLocationEnabled = true 
    myView = mapView 

但谷歌地圖仍然沒有顯示。

有沒有人知道問題在哪裏?

非常感謝。

回答

2

的問題是你有初始化mapViewCGRect.zero所以框架(0.0, 0.0, 0.0, 0.0)意味着0 width0 height,而不是設置該frame正確喜歡你view.bounds

let mapView = GMSMapView.map(withFrame: self.view.bounds, camera: camera) 
+0

非常感謝你。這是正確的! – dickfala

+0

@dickfala歡迎隊友:) –