小编use*_*576的帖子

navigator.geolocation.getCurrentPosition始终获取错误代码3:超时已过期

我使用cordova-2.0.0和android模拟器google api level16.

每当我跑步,navigator.geolocation.getCurrentPosition我总是得到error3.我的代码简介如下:

     // Wait for Cordova to load
            document.addEventListener("deviceready", onDeviceReady, false);

            // Cordova is ready
            function onDeviceReady() {
                console.log("Entering index.html.onDeviceReady");
                var networkState = navigator.network.connection.type;
                getPosition(networkState);
}

function getPosition(networkState) {
    console.log("Entering getPosition function");
    console.log("networkState is: " + networkState);
    if (networkState !== null) {
        navigator.geolocation.getCurrentPosition(onSuccess, onError, {
            maximumAge : Infinity,
            timeout : 5000,
            enableHighAccuracy : true
        });
    } else {
        alert('Please check your network connection and try again.');
    }
    console.log("Leaving getPosition function");
}

// function for …
Run Code Online (Sandbox Code Playgroud)

android geolocation

11
推荐指数
2
解决办法
1万
查看次数

标签 统计

android ×1

geolocation ×1