Google maps not display about new version with xcode8.2

妖精的绣舞 提交于 2019-12-13 07:23:33

问题


I try to use the Google Maps SDK for iOS with the Swift and Xcode 8.2.

I had set the API Key correct.

I using the Google Map SDK website sample code.

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

It will show the errors:

'cameraWithLatitude(_:longitude:zoom:)' has been renamed to 'camera(withLatitude:longitude:zoom:)'

swift:84:47: 'CGRectZero' is unavailable in Swift

swift:85:17: 'myLocationEnabled' has been renamed to 'isMyLocationEnabled'

So I change the to like below:

   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

But the google map is still not display.

Have anyone known where is the problem?

Thank you very much.


回答1:


The problem is you have initialized mapView with CGRect.zero so the frame is (0.0, 0.0, 0.0, 0.0) means 0 width and 0 height, instead of that set the frame properly like your view.bounds.

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



回答2:


Have your Enable API at API Consol



来源:https://stackoverflow.com/questions/41157184/google-maps-not-display-about-new-version-with-xcode8-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!