这是我的$cordovaGeolocation
插件代码
function getLoc(){
var posOptions = {timeout: 10000, enableHighAccuracy: false};
$cordovaGeolocation
.getCurrentPosition(posOptions)
.then(function (position) {
currentLocation = position;
deferred.resolve(position.coords);
}, function(err) {
console.log("Error getting current location"+JSON.stringify(err));
deferred.reject(err);
});
return deferred.promise;
}
当我运行我的应用并且位置尚未启用时,它会显示错误{code: 3, message: "Timeout expired"}
。应用程序打开后我启用位置此显示错误。
要在启用位置后获取位置,我将重新启动我的应用程序。