Skip to content

Instantly share code, notes, and snippets.

@stereoket
Created February 16, 2011 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stereoket/829422 to your computer and use it in GitHub Desktop.
Save stereoket/829422 to your computer and use it in GitHub Desktop.
Trying to understand why event listener does not close down
Ti.Geolocation.getCurrentPosition(function(e)
{
if (!e.success || e.error)
{
Ti.API.debug('error ' + JSON.stringify(e.error));
return;
}
Ti.Geolocation.addEventListener('location',function(e)
{
if (!e.success || e.error)
{
return;
}
function IsNumeric(input)
{
return (input - 0) == input && input.length > 0;
}
MyClass.latitude = e.coords.latitude;
MyClass.longitude = e.coords.longitude;
MyClass.latlong = e.coords.latitude + ',' + e.coords.longitude;
MyClass.accuracy = e.coords.accuracy;
MyClass.timestamp = e.coords.timestamp;
Ti.API.info(e.type + ' handler (' + e.source + ') Accuracy: ' + MyClass.accuracy);
setTimeout(function(e)
{
MyClass.processGeoData(MyClass.latitude,MyClass.longitude);
Ti.API.log('Last location: ' +
new Date(MyClass.timestamp) +
' long ' +
MyClass.longitude +
' lat ' +
MyClass.latitude +
' accuracy ' +
MyClass.accuracy);
}, 2000);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment