views:

631

answers:

2

Using the CLLocationManager object's didUpdateHeading event, how do I convert the resulting heading.x and heading.y values into degrees I can plot onto an image of a compass?

+1  A: 

For headings degrees you can use magneticHeading and trueHeading properties instead of x and y.

trueHeading

The heading (measured in degrees) relative to true North. (read-only)

@property(readonly, nonatomic) CLLocationDirection trueHeading

Discussion

The value in this property represents the heading that points toward the geographic North Pole. The value in this property is always reported relative to the top of the device, regardless of the device’s physical or interface orientation. The value 0 represents true North, 90 represents due East, 180 represents due South, and so on. A negative value indicates that the heading could not be determined.

notnoop
+1  A: 

Try:

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading {

   CLLocationDirection true = [newHeading trueHeading];

   CLLocationDirection magnetic = [newHeading magneticHeading];

}

CLLocationDirection is typedef double and so you get the true or magnetic heading in degrees.

James