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 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.
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 ...