Sriram Kalyanasundaram created CB-14214:
-------------------------------------------

             Summary: Timeout when calling getCurrentPosition in Android
                 Key: CB-14214
                 URL: https://issues.apache.org/jira/browse/CB-14214
             Project: Apache Cordova
          Issue Type: Bug
          Components: cordova-plugin-geolocation
            Reporter: Sriram Kalyanasundaram


Location is turned on the phone

Code : 


var app = {
 // Application Constructor
 initialize: function() {
 document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
 },

 // deviceready Event Handler
 //
 // Bind any cordova events here. Common events are:
 // 'pause', 'resume', etc.
 onDeviceReady: function() {
 this.receivedEvent('deviceready');
 },

 // Update DOM on a Received Event
 receivedEvent: function(id) {
 var parentElement = document.getElementById(id);
 var listeningElement = parentElement.querySelector('.listening');
 var receivedElement = parentElement.querySelector('.received');

 listeningElement.setAttribute('style', 'display:none;');
 receivedElement.setAttribute('style', 'display:block;');

 console.log('Received Event: ' + id);
 navigator.geolocation.getCurrentPosition(onSuccess, onError);
 }
};
var onSuccess = function(position) {
 alert('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: ' + position.timestamp + '\n');
};

// onError Callback receives a PositionError object
//
function onError(error) {
 alert('code: ' + error.code + '\n' +
 'message: ' + error.message + '\n');
}
app.initialize();



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to