iPhone - CLHeading to find direction
Question
In my iPhone application, I'm using using CLLocationManager to find the direction in which my iphone is pointing to. I'm using the property "heading". Its giving me x,y and z values. How can I find from these values in which direction (north or south or east or west) I'm currently pointing to?
Solution
heading
is a CLHeading
object. As one look in the documentation would have told you, it also has properties for the true and magnetic headings in degrees.
OTHER TIPS
you should use method [locationManager startUpdateHeading]
to enable get the angle relative to the geographic North Pole or magnetic North Pole. Then you can get the value in
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
NSLog(@"%f",newHeading.trueHeading);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow