Search code examples
objective-ciosios4cllocationmanagercllocation

iOS CoreLocation CLHeading - update heading to CLLocation


I'm in desperate need to constantly find the heading angel between my device/location and a specific location instead of NORTH. I'm getting didUpdateHeading and calculating the angel to the NORTH but how can I do it to a specific latitude, longitude?

Thank you.


Solution

  • You know your current position (latitude, longitude) and you know your destination (latitude, longitude). You therefore can calculate the heading which is desired using basic trig.

    You can obtain your current heading relative to true north from the location manager.

    Now, simply obtain the difference between the two which is the direction of your target.