小编Dan*_*ary的帖子

HKWorkoutRouteBuilder 和 CLLocationManager 仅增量添加路线更新

我在 watchOS 上有一个功能锻炼应用程序,用于跟踪室内和室外跑步。我正在尝试使用 HKWorkoutRouteBuilder 将户外跑步路线添加到 HealthKit。实际户外跑步期间的实际测试仅在地图上显示部分路线更新,如下图所示,为一小串蓝点;

跑步路线

路线更新来自我在下面的课程中设置的 CoreLocation。

class LocationManager: NSObject, CLLocationManagerDelegate {

    public var globalLocationManager: CLLocationManager?
    private var routeBuilder: HKWorkoutRouteBuilder?

    public func setUpLocationManager() {
        globalLocationManager = CLLocationManager()
        globalLocationManager?.delegate = self
        globalLocationManager?.desiredAccuracy = kCLLocationAccuracyBest
        // Update every 13.5 meters in order to achieve updates no faster than once every 3sec.
        // This assumes runner is running at no faster than 6min/mile - 3.7min/km
        globalLocationManager?.distanceFilter = 13.5
        // Can use `kCLDistanceFilterNone`  which will give more updates but still only at wide …
Run Code Online (Sandbox Code Playgroud)

core-location swift healthkit watchos swiftui

5
推荐指数
1
解决办法
1225
查看次数

标签 统计

core-location ×1

healthkit ×1

swift ×1

swiftui ×1

watchos ×1