O'Reilly logo

Appcelerator Titanium Smartphone App Development Cookbook - Second Edition by Jason Kneen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Monitoring your heading using the device compass

This time , in our last recipe for this chapter on Maps and GPS, we will be using the inbuilt device compass to determine the heading. We'll present this heading using an image of an arrow to represent the direction visually.

Note

Note that this recipe will not work on older iPhone devices, such as iPhone 3G; they lack the compass. You will need to use an actual device to test this recipe, as the emulator will not be able to get your current heading either.

The complete source code for this recipe can be found in the /Chapter 3/Recipe 7 folder.

How to do it...

Add the following code to your app.js file, just before you perform the win1.open() method call at the end of the file:

//this image will appear ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required