gpt4 book ai didi

ios - swift 谷歌地图不显示

转载 作者:搜寻专家 更新时间:2023-11-01 06:01:35 25 4
gpt4 key购买 nike

在 Xcode9.2 上遵循此代码

@IBOutlet weak var mView: UIView!
let locationManager = CLLocationManager()
var mapView: GMSMapView!

var currentLatitude:Double = 0.0
var currentLongtitude:Double = 0.0
var heading = 0.00

override func viewDidLoad() {
super.viewDidLoad()


if CLLocationManager.locationServicesEnabled() {
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}

let camera = GMSCameraPosition.camera(withLatitude: locationManager.location!.coordinate.latitude, longitude:
locationManager.location!.coordinate.longitude, zoom: 15);

mapView = GMSMapView.map(withFrame: self.view.bounds, camera: camera)
mapView.delegate = self
self.mView = mapView
mapView.settings.myLocationButton = true
mapView.isMyLocationEnabled = true
}

如果我用

self.View = mapView

它工作得很好但是

self.mView = mapView

它不起作用,为什么? mMapview 是白色的。

最佳答案

如果您将 mapview 放在 Storyboard或 xib 上,则可以通过使用 self.mView = mapView 对其进行分配来覆盖它。相反,应该已经有一个实例化的 self.mView,您可以将 mapView = GMSMapView.map(withFrame: self.view.bounds, camera: camera) 更改为 self.mView.camera = camera,以及 mapView 下面的所有其他实例到 self.mView

如果没有,您可以完全删除 self.mView 并只使用 mapView。将 self.view.addSubview(mapView) 添加到您的 viewDidLoad 的底部,您将被设置。

关于ios - swift 谷歌地图不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48427672/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com