Skip to content

Instantly share code, notes, and snippets.

@aaronksaunders
Created October 7, 2011 17:39
Show Gist options
  • Select an option

  • Save aaronksaunders/1270894 to your computer and use it in GitHub Desktop.

Select an option

Save aaronksaunders/1270894 to your computer and use it in GitHub Desktop.
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
Titanium.Geolocation.distanceFilter = .25;
Ti.Geolocation.purpose = "Callbacks Are Your Friend";
// global to hold the coords from the callback
var global_var_coords;
// make the API call
Ti.Geolocation.getCurrentPosition(function(e) {
// do this stuff when you have a position, OR an error
if (e.error) {
Ti.API.error('geo - current position' + e.error);
return;
}
// got the location information
Ti.App.info('got a location ',JSON.stringify(e));
// set a global variable
global_var_coords = e.coords
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment