【问题标题】:getCurrentPosition() is not working on google chromegetCurrentPosition() 不适用于谷歌浏览器
【发布时间】:2021-06-25 09:29:39
【问题描述】:
window.addEventListener("load", () => {
    let lat;
    let long;

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

错误:[弃用] getCurrentPosition() 和 watchPosition() 不再适用于不安全的来源。要使用此功能,您应该考虑将您的应用程序切换到安全来源,例如 HTTPS。

【问题讨论】:

    标签: javascript


    【解决方案1】:

    出于安全原因,getCurrentPosition() 在 Chrome 和其他浏览器中的非安全协议上被阻止。您需要安装 SSL 证书

    【讨论】:

    • *在非安全架构上被阻止
    猜你喜欢
    • 2012-09-19
    • 2018-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-03
    • 2014-11-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多