Google 地图不显示关于 xcode8.2 的新版本
Google maps not display about new version with xcode8.2
我尝试将 Google Maps SDK iOS 与 Swift 和 Xcode 8.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(_: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'
所以我将其更改为如下所示:
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
但是google地图还是没有显示。
有谁知道问题出在哪里?
非常感谢。
问题是你已经用 CGRect.zero
初始化了 mapView
所以框架是 (0.0, 0.0, 0.0, 0.0)
意味着 0 width
和 0 height
,而不是设置 frame
很喜欢你的 view.bounds
.
let mapView = GMSMapView.map(withFrame: self.view.bounds, camera: camera)
启用 API
我尝试将 Google Maps SDK iOS 与 Swift 和 Xcode 8.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(_: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'
所以我将其更改为如下所示:
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
但是google地图还是没有显示。
有谁知道问题出在哪里?
非常感谢。
问题是你已经用 CGRect.zero
初始化了 mapView
所以框架是 (0.0, 0.0, 0.0, 0.0)
意味着 0 width
和 0 height
,而不是设置 frame
很喜欢你的 view.bounds
.
let mapView = GMSMapView.map(withFrame: self.view.bounds, camera: camera)