This website does not have permission to use the Geolocation API

你说的曾经没有我的故事 提交于 2021-02-19 06:23:05

问题


I am expericing this error, while trying to use the geolocation api:

This website does not have permission to use the Geolocation API

The strange thing is that the same website is running fine on one some systems(where IE.9 and I.E10 are installed) and it throws error on a system where I.E 9 is installed.

We tested it on different systems but it throws error only on that particular system where I.E9 is installed.

  • Do we need some browser settings to use this API?
  • What persmission do we require for our website, to use the geolocation 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");
    }

}

In case of success:

function geolocationSuccess(position) {

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



}

In case of error:

function geolocationError(positionError) {

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


}

回答1:


This could be a Windows setting, at least it was in my case. Try going to Settings (search from the Start menu in Windows) > Privacy > Location and turn Location = On.




回答2:


Follow the instructions below for IE:

  • Open Tools>> Internet Options >> see below image

enter image description here




回答3:


For Windows 10 you may need to turn on "Location service" in Settings > Privacy > Location before you turn it on in Internet Explorer.

See: Windows 10 location service and privacy




回答4:


Do note that if you get this problem in windows phone while developing mobile apps, the website should be something like: "http://www.geo.com/geo". If the domain is a certain ip address, say: "192.168.1.2", ie "http://192.168.1.2/geo", you can never get through it!



来源:https://stackoverflow.com/questions/15742997/this-website-does-not-have-permission-to-use-the-geolocation-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!