简体   繁体   English

getCurrentPosition() 不适用于谷歌浏览器

[英]getCurrentPosition() is not working on google chrome

window.addEventListener("load", () => {
    let lat;
    let long;

    if(navigator.geolocation){
        navigator.geolocation.getCurrentPosition(position => {
        console.log(position);
        })
    }
})

Error : [Deprecation] getCurrentPosition() and watchPosition() no longer work on insecure origins.错误:[弃用] getCurrentPosition() 和 watchPosition() 不再适用于不安全的来源。 To use this feature, you should consider switching your application to a secure origin, such as HTTPS.要使用此功能,您应该考虑将应用程序切换到安全来源,例如 HTTPS。

getCurrentPosition() is blocked on non-secure protocols in Chrome and other browsers for security reasons.出于安全原因,Chrome 和其他浏览器中的非安全协议阻止了getCurrentPosition() You need to install SSL Certificate您需要安装 SSL 证书

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM