我在尝试使用地理位置 api 时遇到此错误:
This website does not have permission to use the Geolocation API
奇怪的是,同一个网站在某些系统上运行良好(其中IE.9 和 I.E10已安装)并且它会在系统上抛出错误I.E 9已安装。
我们在不同的系统上测试了它,但它仅在该特定系统上抛出错误I.E9已安装。
- 我们需要一些浏览器设置才能使用这个 API 吗?
- 我们的网站需要什么许可才能使用地理定位 API?
Code:
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.");
}
这可能是 Windows 设置,至少就我而言是这样。尝试转至“设置”(从 Windows 的“开始”菜单搜索)>“隐私”>“位置”,然后将“位置”设置为“开”。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)