var options = {timeout: 50000,maximumAge:Infinity, enableHighAccuracy: true};
$cordovaGeolocation.getCurrentPosition(options).then(function(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
var time= position.coords.timestamp
alert(lat)
console.log(lat, lng);
$scope.location = lat + ’ ’ + lng;
}, function(error) {
console.log('Could not get location: ', error);
alert(error) //every time this alert give position error
});
})
//I am getting time out error
please Help me
Please check at your localhost/address bar towards the right order , might be a case that you have disabled the current location look for this symbol
It is working in browser and android redmi 2s v 5.1 and samsung mobile but it is not working in htc desire
and giving timeout expired
thanks for reply
just Try with enable enableHighAccuracy: false
some of my device not working with “true” value.
I tried with enableHighAccuracy: false , i got same error
I restarted my mobile and It is working very fine with enableHighAccuracy: false/true
1 Like
$scope.watchOptions = { timeout: 6060 1000, enableHighAccuracy: false, maxAge: 1000, };
$scope.locWatch = $cordovaGeolocation.watchPosition($scope.watchOptions);
$scope.locWatch.then(null, function (err) {
//ionicToast.show('Unable to get location', "top", true, 2500);
}, function (position) {
var lat = position.coords.latitude;
var lon = position.coords.longitude;
});
try this also
yup it is working both readmi 2s and htc
thanks for your suggetion
1 Like