Geolocation
Geolocation allows you to grab the location of the phone. The code can be used in two ways; either as a single call to get the current location, or you can continually track the location of the phone by setting up an event listener. As with the other gadgets, if you do choose to track the location, have a good reason for doing so and only track for as long as you need to, as you will drain the battery.
If you are going to get the phone location or use the phone's compass, the users have to give you permission to grab their location. iOS will show an alert dialog when you first attempt to use location functionality. You should explain the reason why you are interested in the user's location by setting Ti.Geolocation.purpose
before the code to get the location. The following is an example call to set the purpose:
Ti.Geolocation.purpose = 'To display your current co-ordinates';
This will result in the following screenshot when the device tries to get the location:
Note
You only need...