Tracking direction and speed

The GeoLocation object in Sencha Touch provides properties which we can use to figure out the direction and the speed at which we are moving. This could be useful in applications where you may want to suggest to the user the nearest petrol pump based on his direction. In this recipe, we will look at the use of related properties.

Getting ready

Make sure that you have set up your development environment by following the recipes outlined in Chapter 1.

How to do it...

Carry out the following steps:

  1. In the locationupdate event handler, add the following line of code:
    alert('Heading: ' + geo.heading + ': Speed:' + geo.speed);
  2. Deploy and access it from the device of your choice.

How it works...

The preceding code uses the two important ...

Get Sencha Touch Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.