No matter what the timeout is set or whether the high accuracy is true or false !!
$cordovageolocation always returning error code 3 error message Timeout expired
$cordovaGeolocation.getCurrentPosition(posOptions).then(function (position) {
var lat = position.coords.latitude;
var long = position.coords.longitude;
//alert(lat);
var FormData = {
'radius' : $localStorage.nearradius,
'latitude' : lat,
'longitude' : long
};
$http({
method: 'POST',
url: 'http://xyz.com/abc',
data: FormData,
headers: {'Content-Type': 'application/x-www-form-urlencoded','Authorization':undefined},
})
.success(function(data) {
Thanks for your response ! its background geolocation plugin which will keep running i guess ! i just want to check/get user’s location once ! can i do that ?
yess ! i have ! for debugging purpose i placed a alert for plugin’s response !
and plugin always times out with error code 3 that is timeout message according to documentation too…
maximum age should also be higher than 0 as this is not giving your gps chip long enough time to acquire a new gps hit. try 30 seconds as a test.
TIMEOUT (numeric value 3)
The length of time specified by the timeout property has elapsed before the implementation could successfully acquire a new Position object.
This is a very simple example, but I hope to help you:
function getLocation() {
return $cordovaGeolocation.getCurrentPosiion();
}
function loadingLocation(deferred) {
getLocation()
.then(function(response) {
deferred.resolve(response); // resolve the success value
})
.catch(function() {
getLocation(deferred); //when can not get location call again getLocation till success
});
return deferred;
}
var defer = $q.defer();
loadingLocation(defer); // this will return promise which will be resolved only with success