在Swift中查看GoogleMaps视图? [英] Show GoogleMaps on View in Swift?

查看:203
本文介绍了在Swift中查看GoogleMaps视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码:

  var camera = GMSCameraPosition.cameraWithLatitude(currentLocation.latitude,longitude:currentLocation.longitude,zoom:12 )
//经度,纬度如:31.230416和121.473701。
let map = GMSMapView(frame:CGRectZero)
map.delegate = self
map.camera = camera
self.view = map

工作正常!像这样:





但是当我创建新的View : @IBOutlet weak var mapView:UIView!

然后改变这一行: self。 view = map to self.mapView = map



我得到一个空白的视图。

解决方案

我通过转到我的视图(视图显示地图)到GMSMapView。


My code:

var camera = GMSCameraPosition.cameraWithLatitude(currentLocation.latitude, longitude: currentLocation.longitude, zoom: 12) 
//latitude, longitude like :31.230416 and 121.473701.
let map = GMSMapView(frame: CGRectZero)
map.delegate = self
map.camera = camera
self.view = map

It work fine! like this:

But when I create new View: @IBOutlet weak var mapView: UIView!

Then change this line: self.view = map to self.mapView = map

It not work for me, I get a blank view.

解决方案

I fixed it by go to my view (view display map), then change class my view to GMSMapView.

这篇关于在Swift中查看GoogleMaps视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆