float LocationGetHeading();


Gets the current heading (in degrees, relative to magnetic north) of the device.


Return Value


Returns a non-zero value if the call was successful, negative otherwise.




LocationGetHeading() returns the current heading in degrees relative to magnetic north.


Heading data is not available on all devices, as it requires a magnetometer.


Windows Simulator NOTE: To provide values for the Windows Simulator, be sure to edit C:\DragonFireSDK\DragonFireSDK.ini and modify the value for Heading in the Location section.


NOTE: It is recommended to call LocationMonitorHeading() prior to calling LocationGetHeading().  This gives the device time to begin receiving more and more accurate heading data prior to getting  heading data.  Subsequent calls to LocationGetHeading() may become more accurate over time as the device pinpoints your location.




Available in DragonFireSDK 1.4 and later on devices with a magnetometer.




#include "DragonFireSDK.h"


int MyFont;

int HeadingText;

char TextBuffer[100];


void AppMain()




  // Begin monitoring heading



  MyFont = FontAdd("Helvetica", "Regular", 24, 0x00FF00);

  HeadingText = TextAdd(10, 10, "Heading:", MyFont);




void OnTimer()


  float heading;


  heading = LocationGetHeading();


  sprintf(TextBuffer, "Heading: %f degrees", heading);

  TextSetText(HeadingText, TextBuffer);




void AppExit()