HTML5地理位置不准确

时间:2015-05-05 08:44:53

标签: html5 google-maps geolocation

我使用以下代码来获取当前位置。但产生的经度和纬度并不准确。它显示距离我的位置约700公里的位置。我怎样才能准确?

<script>
    var x = document.getElementById("demo");
    function getLocation() {
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(showPosition);
        } else {
            x.innerHTML = "Geolocation is not supported by this browser.";
        }
    }
    function showPosition(position) {
        x.innerHTML = "Latitude: " + position.coords.latitude + 
        "<br>Longitude: " + position.coords.longitude; 
    }
    </script>

1 个答案:

答案 0 :(得分:1)

或者您可以尝试使用其他地理编码提供商。

有很多选择:

免责声明:我是SmartyStreets的开发人员。

相关问题