Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // file_with_location.js
- //
- Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
- Titanium.Geolocation.distanceFilter = .25;
- Ti.Geolocation.purpose = "Callbacks Are Your Friend";
- /**
- * @param {Object} _callback call on completion of location query
- */
- function currentLocation(_callback) {
- // 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);
- // to keep it simple, just returning null, could be
- // error information
- if (_callback) {
- _callback(null);
- }
- return;
- }
- // got the location information
- Ti.App.info('got a location ',JSON.stringify(e));
- // fire and event containing the location information
- Ti.App.fireEvent('location.updated',e.coords);
- // call callback with coords
- if (_callback) {
- _callback(e.coords);
- }
- });
- }
Add Comment
Please, Sign In to add comment