Javascript Cordova getCurrentPosition()永远不会返回

Javascript Cordova getCurrentPosition()永远不会返回,javascript,android,cordova,geolocation,cyanogenmod,Javascript,Android,Cordova,Geolocation,Cyanogenmod,我的cordova版本是6.3.1,我正在使用cordova插件geolocation 2.3.0。 调用navigator.geolocation.getCurrentPosition(onSuccess,onError)时,onSuccess或onError都不会被触发 我还尝试使用cordova plugin locationservices插件,该插件利用Google Play服务获取用户位置,但结果相同。我正在为CyanogenMod 13(Android 6)构建,并使用microG

我的cordova版本是6.3.1,我正在使用cordova插件geolocation 2.3.0。
调用
navigator.geolocation.getCurrentPosition(onSuccess,onError)
时,
onSuccess
onError
都不会被触发
我还尝试使用cordova plugin locationservices插件,该插件利用Google Play服务获取用户位置,但结果相同。
我正在为CyanogenMod 13(Android 6)构建,并使用microG为Google Play服务构建(迄今为止,我遇到的所有其他应用程序都可以使用它)。
代码如下,提前谢谢

    setInterval(function(){
       cordova.plugins.locationServices.geolocation.getCurrentPosition(function(pos) { /* cordova-plugin-locationservices */
       //navigator.geolocation.getCurrentPosition(function(pos) { /* cordova-plugin-geolocation */
          alert('Location determined');
          console.log(pos);
        }, function(err) {
          alert('code: ' + err.code + '\n message: ' + err.message);
        });
    },3000);

您必须给option对象一个timeout属性,因为如果您不这样做,android设备将不会触发错误回调,因此您不会看到任何错误

setInterval(function(){
       cordova.plugins.locationServices.geolocation.getCurrentPosition(function(pos) { /* cordova-plugin-locationservices */
       //navigator.geolocation.getCurrentPosition(function(pos) { /* cordova-plugin-geolocation */
          alert('Location determined');
          console.log(pos);
        }, function(err) {
          alert('code: ' + err.code + '\n message: ' + err.message);
        }, { timeout: 5000} );
    },3000);

参见文档:

谢谢,这为我指明了正确的方向。我最终收到一个错误,说明“接收位置时超时”,这将我指向,并解决了问题。干杯