Find the direction of motion?

579 views Asked by At

I have an image(floor plan) where i pinned my current position. with CMPedometer I am able to find the number of steps moved but couldn't 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 any way of finding the direction i am moving (relevant to my point OR to E,W,S,N ) ?

1

There are 1 answers

0
Alex Motor On

CMMotionManager provides you API to work with Magnetometer.

It should be use to determine heading (North).