在Swift中的View上显示GoogleMaps?
我的代码:
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
它工作正常! 喜欢这个:
但是当我创建新的View时: @IBOutlet weak var mapView: UIView!
然后更改此行: self.mapView = map
to self.mapView = map
它不适合我,我得到一个空白的视图。
我通过转到我的视图(查看显示地图)修复它,然后将我的视图更改为GMSMapView。