API of current geolocation position does not work in IE11.5 windows10

API of current geolocation position is incompatible in IE11 Windows 10 machine. Below is the code

 function setCurrentPos(event, firstLoad) {
                navigator.geolocation.getCurrentPosition(function (position) {
                    firstLoad || setCurrentLocation(event.target, position.coords);
                }, function (error) {
                    1 === error.code && ($this.currentLocDenied = !0);
                });
            }

      

4 out of 5 times it gets into an error block with response code 2 (POSITION_UNAVAILABLE) with the indication "The current position could not be determined."

In the prompt, the browser that allows the user to access the location is allowed so that this is not the reason.

Version Information

enter image description here Any other suggestions?

+3


source to share


2 answers


Fixed

1 - Changes described below should be added for IE only. So please check if the browser is IE if we need to add a workaround. Don't change others' browser.

2 - Change the precision of enableHighAccuracy to false. I know this is false by default, but just in case.



3 - Add some reasonable value to maximum Age for cache times. (IE only)

var locationOptions = {};
if(deviceInfo.raw.browser.isIE && parseInt(deviceInfo.browser_version) == 11 &&  deviceInfo.os.isWindows10) {
            locationOptions = {
                enableHighAccuracy: false,
                  maximumAge: 50000
            }
    }

function setCurrentPos(event, firstLoad) {
                navigator.geolocation.getCurrentPosition(function (position) {
                    //success callback
                }, function (error) {
                        //error callback
                }, locationOptions);
            }

      

Link - https://msdn.microsoft.com/en-us/library/gg593067(v=vs.85).aspx

+1


source


Until today (4.4.2017) "navigator.geolocation.getCurrentPosition" works fine under win10 preview 15063.11 + IE11, Edge, FF. BUT today only timeout error occurs. So something big is happening on the net right now



* Updated: as of 5.4.2017 everything works fine again

0


source







All Articles