Time for action – getting the current location
Perform the following steps to get the current location:
Create a new blank mobile app by clicking on File | New | Titanium Project. Don't use a template as it will just generate code that gets in the way.
Create the window for the app:
var win1 = Titanium.UI.createWindow({ backgroundColor:'#fff' });
We need to check that we are allowed to grab the location of the phone. Because there are a few platform differences in how you do this; it's best to wrap it all into a function so that the caller of the function isn't troubled with this detail:
function isLocationAuthorized(_args) { //check that we are allowed to use var retVal = true; if (!Ti.Geolocation.locationServicesEnabled) return false; // Explain to the user why we are going to use the location services. Ti.Geolocation.purpose = _args.purpose; var authorization = Titanium.Geolocation.locationServicesAuthorization; if (authorization...