Measuring Direction with the Compass

The compass, also known as the magnetometer, is a Windows Phone required sensor that allows your app to determine which direction the phone is pointing—in particular, the offset from magnetic or geographic north.

The compass is useful in applications that use geographic location; for example, you may want to provide a compass arrow as a supplement for a mapping app. The compass also allows you to monitor raw magnetometer readings and to detect changes to magnetic forces around the device.

The sample code for this section creates a page that displays a compass arrow and the various compass readings, and you see how to allow the user to calibrate the compass.

The sample code for this section resides in the ...

Get Windows® Phone 8 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.