获取位置需要重新启动应用程序

时间:2016-08-10 16:08:53

标签: cordova ionic-framework ngcordova

这是我的$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"}。应用程序打开后我启用位置此显示错误。 要在启用位置后获取位置,我将重新启动我的应用程序。

0 个答案:

没有答案