Use a device's orientation and course information for navigation.
- Core Location
Heading and course information are commonly used by navigation apps to help guide the user to a destination. The heading of a user's device is its current orientation relative to magnetic or true north. Devices with GPS can report course information, which represents the direction in which the device is moving. The Compass app in iOS uses heading information to implement a magnetic compass interface, as shown in Figure 1. Augmented reality apps might use this information to determine which direction the user is facing.
Get the Current Heading
You use heading information to determine the current orientation of the user's device. For example, an augmented reality app might use the current heading to help determine what information to show on the user's screen. Headings are usually reported relative to the top of the device, but you can configure how values are reported using the
heading property of your
After determining whether heading information is available, call the
start method of your
CLLocation object to begin the delivery of heading updates. The location manager delivers updates to the
location method of its delegate whenever the heading information changes.
Get Course Information
Course information reflects the speed and direction in which a device is moving and is available only on devices with GPS hardware. Do not confuse course information with heading information. Course direction reflects the direction in which the device is moving and is independent of the device’s physical orientation. The most common use of course information is in navigation apps.
Course information is included automatically in
CLLocation objects delivered to your app as part of its location updates. When enough location data has been gathered to compute a course, the location manager fills in the
course properties of the location object with the appropriate values.