本网站无权使用Geolocation API

Yaq*_*mad 2 internet-explorer geolocation

我正在尝试使用geolocation api时遇到此错误:

This website does not have permission to use the Geolocation API
Run Code Online (Sandbox Code Playgroud)

奇怪的是,同一个网站在某些系统(安装了IE.9和I.E10)上运行良好,并且在安装IE 9的系统上抛出错误.

我们在不同的系统上测试了它,但它只在安装了I.E9的特定系统上抛出错误.

  • 我们是否需要一些浏览器设置才能使用此API?
  • 我们的网站要求使用地理定位API需要什么?

代码:

function geolocateUser()
{
    // If the browser supports the Geolocation API
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(geolocationSuccess, geolocationError);
    }
    else {
        alert("Your browser doesn't support the Geolocation API");
    }

}
Run Code Online (Sandbox Code Playgroud)

如果成功:

function geolocationSuccess(position) {

    var userCurrentLatLong = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);



}
Run Code Online (Sandbox Code Playgroud)

如果有错误:

function geolocationError(positionError) {

    alert(positionError.message + "\n" + "you will be redirected to default location.");


}
Run Code Online (Sandbox Code Playgroud)

小智 7

这可能是一个Windows设置,至少在我的情况下.尝试转到"设置"(从Windows的"开始"菜单中搜索)>"隐私">"位置",然后转到"位置=开".