Ok i have spent lots of time to find issue but unable to detect , i am able to get current location on browser but its not working on real device ( mine is nexus 5 ) , Found this logs while debugging application. What am i doing wrong, do i miss anything ?
PositionError
code: 3
message: "Timeout expired"
__proto__: PositionError
PERMISSION_DENIED: 1
POSITION_UNAVAILABLE: 2
TIMEOUT: 3
code: (...)
get code: ()
constructor: PositionError()
message: (...)
get message: ()
__proto__: Object
document.addEventListener(“deviceready”, onDeviceReady, false);
function onDeviceReady() {
var posOptions = {
enableHighAccuracy: true,
timeout: 310000,
maximumAge: 90000
};
$ionicLoading.show({
template: '<ion-spinner icon="bubbles"></ion-spinner><br/>Acquiring location!'
});
$cordovaGeolocation.getCurrentPosition(posOptions).then(function (position) {
lat = position.coords.latitude;
long = position.coords.longitude;
$ionicLoading.hide();
$ionicLoading.show({ template:"Current Location :" + "lat :"+lat +", long :"+long, noBackdrop: true, duration: 2000 });
}, function(err) {
$ionicLoading.hide();
$ionicLoading.show({ template:"Current Location :" + err, noBackdrop: true, duration: 2000 });
console.log(err);
});
}
Greetings,
I am having exactly the same issue. The irritating part is that this used to work without a problem on the device as well.
Did you find the solution for this by any chance?
Regards,
Sean
@seanmtebe can you paste your code here?
function getLatLong()
{
var posOptions = {timeout: 50000, enableHighAccuracy: false};
$cordovaGeolocation.getCurrentPosition(posOptions).then(function (position) {
var lat = position.coords.latitude;
var long = position.coords.longitude;
$scope.checkinr.deviceLat = lat;
$scope.checkinr.deviceLong = long;
$scope.checkinr.appStatus = ‘green’;
$ionicLoading.hide();
}, function(err) {
console.log(err);
$ionicLoading.hide();
showAlert('Acquire Location', 'An error occurred whilst trying to acquire location!');
});
//console.log($scope.checkinr.deviceLat);
var watchOptions = {
timeout : 50000,
enableHighAccuracy: false
};
var watch = $cordovaGeolocation.watchPosition(watchOptions);
watch.then(
null,
function(err) {
console.log(err);
},
function(position) {
var lat = position.coords.latitude;
var long = position.coords.longitude;
});
watch.clearWatch();
}
The error is timeout expired
Hi can you check with this
navigator.geolocation.getCurrentPosition(function (pos) {
console.log(pos);
});
debug it and check what is coming in pos
That brings back Geoposition on the browser but nothing at all on the emulator.
Actually on the emulator it also brings back timeout expired.
I even went back to a version on SVN that used to work and sill getting the same issue,