我已经在Objective-C中添加了带pods的GoogleMap SDK。
我正在使用桥头在Swift项目中使用。
在appdelegate中,我使用以下代码来提供api密钥
GoogleMapsService.provideAPIKey(kGooglePlacesApiKey)
// where kGooglePlacesApiKey is the key generated on google console.在ViewController中,我使用以下代码添加谷歌地图
func addGoogleMap()
{
let camera = GMSCameraPosition.cameraWithLatitude(51.5074,
longitude: 0.1278, zoom: 10)
mapView = GMSMapView.mapWithFrame(CGRectMake(0, 157, self.view.frame.size.width, self.view.frame.size.height - 206.1), camera:
camera)
mapView.myLocationEnabled = true
mapView.delegate = self
self.view .addSubview(mapView)
}当我尝试创建GMSMapView的对象时,它总是在这一行崩溃
mapView = GMSMapView.mapWithFrame(CGRectMake(0, 157, self.view.frame.size.width, self.view.frame.size.height - 206.1), camera:
camera)它没有给出任何错误日志,它只是切换到appdelegate,并以红色显示错误。

发布于 2016-09-16 19:42:34
创建将所需边框设置为地图视图边框的CGRect
var gframe = CGRectMake(0, 157, self.view.frame.size.width, self.view.frame.size.height - 206.1)
mapView = GMSMapView.mapWithFrame(gframe, camera:camera)https://stackoverflow.com/questions/39529414
复制相似问题