【发布时间】:2017-03-15 12:42:25
【问题描述】:
我有一个 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
我只是不知道现在该去哪里。
最终我试图让它绘制一条路线并允许您从当前位置导航到目标位置。
【问题讨论】: