我在线跟踪了一些文档here来设置谷歌地图API,我可以将其加载到视图中。我确实有一个问题 - 当我获得用户的位置时,谷歌地图的视图不会显示/捕捉/动画到用户的位置。我能够成功获得用户的位置。
我的位置经理:
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]){
let newUserLocation: CLLocation = locations[0]
let latitude: CLLocationDegrees = newUserLocation.coordinate.latitude
let longitude: CLLocationDegrees = newUserLocation.coordinate.longitude
userLocation = PFGeoPoint(latitude:latitude, longitude:longitude)
let Camera = GMSCameraPosition.camera(withLatitude: userLocation.latitude, longitude: userLocation.longitude, zoom: 15)
self.MapView.isMyLocationEnabled = true
self.MapView = GMSMapView.map(withFrame: CGRect.zero , camera: Camera)
}
我的Viewdidload:
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
}
答案 0 :(得分:0)
我找到了一个解决方法,不确定这是否有效但是,它在我的ios模拟器中适用于我。我在创建Camera变量后最终添加了这两行代码:
MapView.animate(toLocation: newUserLocation.coordinate)
MapView.animate(toZoom: 15)