Javascript navigator.geolocation错误函数触发两次

Javascript navigator.geolocation错误函数触发两次,javascript,Javascript,我正在请求我的用户允许我使用以下功能从他们的浏览器中获取他们的位置: if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(set_map_location,geoloc_error,{ enableHighAccuracy:false, maximumAge:85000, timeout:15000 }); } 如果出现问题或进程超时,则调用我

我正在请求我的用户允许我使用以下功能从他们的浏览器中获取他们的位置:

if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(set_map_location,geoloc_error,{
        enableHighAccuracy:false,
        maximumAge:85000,
        timeout:15000
    });
}
如果出现问题或进程超时,则调用我的geoloc_err函数:

function geoloc_error(err) {
    if (err.code == 1) {
        alert("You denied the browser access to your location."
        + "\nYou can find your position manually by dragging the map and zooming in/out.");
    } else if (err.code == 2) {
        alert("The geolocation network is not available or your position could not be found."
        + "\nYou can find your position manually by dragging the map and zooming in/out.");
    } else {
        alert("The browser took too long to find your location. Trying again can sometimes yield different results.\n"
        + "You can find your position manually by dragging the map and zooming in/out.");
    }
}
现在,有时会发生错误,例如,err.code==2网络不可用,会弹出警报并警告我。问题是,几秒钟后,另一个警报框警告我进程也已超时

我的问题是,如何阻止第二个错误警告的发生?我无法退出该函数,因为正在从第一个函数调用错误。

这可能会有所帮助