Find the direction of travel?

I have an image (floor plan) where I have attached my current position. c CMPedometerI can find the number of steps, but could not find the direction in which I am moving.

if(CMPedometer.isStepCountingAvailable()){

    self.pedoMeter.startUpdates(from: midnightOfToday) { (data: CMPedometerData?, error) -> Void in

        DispatchQueue.main.async(execute: { () -> Void in
            if(error == nil) {
                self.stepsLabel.text = "Moved \(data!.numberOfSteps) steps"
            }
        })
    }
}

Is there a way to find the direction I'm moving (as applied to my point OR to E, W, S, N)?

+4
source share
1 answer

CMMotionManager provides you with an API for working with a magnetometer.

It should be used to define the heading (north).

0
source

Source: https://habr.com/ru/post/1664293/


All Articles