HTML 5地理位置无法处理Chrome

时间:2017-08-06 09:49:46

标签: javascript html5 google-chrome geolocation weather-api

我正在尝试使用此代码(如下所示)它在Microsoft边缘上工作正常,但在Chrome上却没有,如何让它在chrome上工作?

$(document).ready(function() {

    $("button").click(function() {

        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(showPosition);
        }

        function showPosition(position) {
            $("p").append("Latitude: " + position.coords.latitude +
                "<br>Longitude: " + position.coords.longitude);
        }

    });

});

在chrome中,它甚至会提示允许该位置但不显示坐标。

由于

1 个答案:

答案 0 :(得分:0)

因为他们在HTTP中停止的安全原因。它仅在HTTPS中工作