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

Drawing routes on your MapView

In order to track our movements and draw a route on the map, we need to create an array of points, each with its own latitude and longitude values. The MapView will take in this array of points as a property called route, and draw a series of lines to provide a visual representation of the route for the user.

In this recipe, we will create a timer that records our location every minute and adds it to the points array. When each new point is recorded, we will access the Google Directions API to determine the distance and add it to our overall tally of how far we have traveled.

Note

Note that this recipe has been designed to work on iOS devices and has not been tested on Android. To use this code on Android, you will ...

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