Tutorial 3 — Camera Orientation

Adding Track-Up functionality to the GPS code from Tutorial 2

In Tutorial 2 we added code so that the app can respond to GPS coordinates from the device. Here in Tutorial 3 we will add code so that Track-Up functionality is created. The idea behind Track-Up mode is to rotate the map as the vehicle changes direction.

Step 1

We need to add one new property to ViewController.h:

Step 2

Modify the didUpdateToLocation function in ViewController.m so that this piece of code is added to the end of the function:

This sets the camera orientation in the mapping engine to match the heading reported by the GPS.

Step 3

Add this function to ViewController.m:

This function can handle enabling an disabling of the Track-Up functionality.

Step 4

Add this line to the bottom of the viewDidLoad function in ViewController.m:

Step 5

Run the app. In the iOS Simulator menu bar, choose the Debug menu and then choose the Location item. Choose one of the options that show motion, like "Freeway Drive" or "City Bicycle Ride". Look in the console window of Xcode and you will see the speed and course changing. The map should pan to the new location so that the new location is centered on the screen and rotate the map to demonstrate Track-Up mode.

Step 6

If you get lost or wish to save yourself the typing, simply checkout tutorial3 using these commands:

git reset --hard
git checkout tutorial3

Step 7

Now we would like the add a couple of buttons over the mapping engine to add some basic UI functionality to the app. This is explained Tutorial 4.

You can learn more about the Altus Mapping Engine classes used in this tutorial in the Documentation. If you have any questions about the Altus Mapping Engine, any feature requests or suggestions for improving the Altus Mapping Engine, please send them to [email protected].