admin管理员组文章数量:1415139
Geolocation current position API is inconsistent 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 is falling into the error block with response code 2(POSITION_UNAVAILABLE) stating "The current position could not be determined.".
The browser prompt that appears to allow user to access location is set to allow so that should not be the reason.
Version Info
Any other suggestions??
Geolocation current position API is inconsistent 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 is falling into the error block with response code 2(POSITION_UNAVAILABLE) stating "The current position could not be determined.".
The browser prompt that appears to allow user to access location is set to allow so that should not be the reason.
Version Info
Any other suggestions??
Share Improve this question edited Apr 6, 2017 at 6:23 Novice asked Apr 4, 2017 at 11:51 NoviceNovice 4781 gold badge6 silver badges22 bronze badges 1- I've got the same problem. I'm running IE Version 11.447.14393.0 – neumann1990 Commented Apr 12, 2017 at 18:26
2 Answers
Reset to default 3Fixed
1 – Changes that I described below should be added only for IE. So please check if the browser is IE if we need to add a workaround. Do not change the others browser.
2 – Change the accuracy of enableHighAccuracy to false. I know that is false by default but just in case.
3 – Add some reasonable value on the maximumAge for the cache time. (Just for IE)
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);
}
Reference - https://msdn.microsoft./en-us/library/gg593067(v=vs.85).aspx
Until today (4.4.2017) "navigator.geolocation.getCurrentPosition" works perfect under win10 insider preview 15063.11 + IE11,Edge,FF. BUT today only timeout error is occurs. So something big is happening right now in the network
*Updated: on 5.4.2017 all works fine again
本文标签: javascriptGeolocation Current Position API not working in IE115 windows10Stack Overflow
版权声明:本文标题:javascript - Geolocation Current Position API not working in IE11.5 windows10 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745227853a2648690.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论