ios - 如何修复函数“didUpdateLocations”上的更新用户位置?
问题描述
当用户访问我的应用程序上的地图时,我想更新位置。我使用 funcdidUpdateLocations
获取用户位置,但位置没有更新,当我在真实设备上运行时有一些单位。请帮助我,谢谢。
这是用于应用程序上的谷歌地图 sdk 设计地图。
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let currentLocation = locations.last else {
return
}
//Update Camera
let camera = GMSCameraPosition.camera(withLatitude: currentLocation.coordinate.latitude, longitude: currentLocation.coordinate.longitude, zoom: 18.0)
mapView.animate(to: camera)
if mapView.isHidden {
mapView.isHidden = false
mapView.camera = camera
} else {
mapView.animate(to: camera)
}
帮助我在运行项目时获取确切的用户位置。谢谢你。
解决方案
请实施开始更新用户位置。让我知道它是否仍然无法正常工作
locationManager.delegate = self
locationManager.startUpdatingLocation()
推荐阅读
- html - 如何在 html 和 css 中的图像前面放置以便阅读?
- javascript - Floating Point Number is greater than another floating point by how many points
- swagger-codegen - 我怎样才能使构建失败?
- amazon-web-services - 使用 Terraform 设置 CodePipeline
- r - 在 DESeq2 PCA 上为不同的 geom_point 形状添加黑色轮廓
- pandas - 合并具有不相等行的 Pandas 数据框
- c - 是否有替代方法来检索下面代码中的字符串数据?
- javascript - Nodejs Express 简单导入js文件路由器
- c# - 在 F# 中触发时未调用 C# 事件处理程序
- autosys - 创建 autosys 作业