我有一个mapkit视图,数据正在从前一个视图发送到,这工作正常。我需要了解的是如何将我的源位置设置为用户的当前位置。这是我的代码行代码:mapkit中的当前位置
let sourcelocation = CLLocationCoordinate2D(latitude: track.lat, longitude: track.lon)
let destinationLocation = CLLocationCoordinate2D(latitude: track.lat, longitude: track.lon)
当我运行,显然这使2个引脚完全相同的位置。
我不确定要放入sourceLocation行来显示当前位置。
我在我的代码已经下面几行:
VAR myLocation:CLLocationCoordinate2D
self.locationManager.requestAlwaysAuthorization()
self.locationManager.requestWhenInUseAuthorization()
if CLLocationManager.locationServicesEnabled() {
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.startUpdatingLocation()
}
,我宣布我的委托以:
CLLocationManagerDelegate
我只是不知道从哪里现在出发。
最终,我试图让它绘制一条路线并允许您从当前位置导航到目标位置。
完美谢谢 –