我在尝试使用geolocation api时遇到此错误:
This website does not have permission to use the Geolocation API
奇怪的是,同一个网站在某些系统上运行良好(安装了 IE.9和I.E10 )并且在 IE 9的系统上抛出错误已安装。
我们在不同系统上对其进行了测试,但仅在安装了 I.E9 的特定系统上引发错误。
代码:
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");
}
}
如果成功:
function geolocationSuccess(position) {
var userCurrentLatLong = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
}
如果出现错误:
function geolocationError(positionError) {
alert(positionError.message + "\n" + "you will be redirected to default location.");
}
答案 0 :(得分:6)
这可能是Windows设置,至少在我的情况下。尝试转到“设置”(从Windows的“开始”菜单中搜索)>隐私>位置和转弯位置=开。
答案 1 :(得分:1)
按照以下IE的说明进行操作:
答案 2 :(得分:0)
对于Windows 10,您可能需要打开"位置服务"在设置>隐私>在Internet Explorer中打开它之前的位置。
答案 3 :(得分:-1)
请注意,如果您在开发移动应用时在Windows手机中遇到此问题,则网站应为:“http://www.geo.com/geo
”。如果域名是某个IP地址,请说:“192.168.1.2
”,即“http://192.168.1.2/geo
”,您永远无法通过它!