社工之经度纬度定位-50米以内

https://bbs.ichunqiu.com/thread-23489-1-1.html?from=zh

现在我们打开

http://www.gpsspg.com/maps.htm

把经度纬度写上去

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="button" value="请求位置信息"><br>
<textarea name="content" id="content" cols="30" rows="10"></textarea>
<script>
    window.onload = function () {
        var oBtn = document.getElementsByTagName('input')[0];
        var oTextarea = document.getElementById('content');

        oBtn.onclick = function () {
            navigator.geolocation.getCurrentPosition(function (position) {
                oTextarea.value += "\n 当前经度:"+position.coords.longitude;
                oTextarea.value += "\n 当前纬度:"+position.coords.latitude;
                oTextarea.value += '\n 准确度:' + position.coords.accuracy;
                oTextarea.value += '\n 海拔:' + position.coords.altitude;
                oTextarea.value +='\n 海拔准确度:'+ position.coords.altitudeAccuracy;
                oTextarea.value += '\n 行进方向:' + position.coords.heading;
            }, function (error) {
                console.log(error)
                alert(error.code);
            },{
                enableHighAcuracy : true,
                timeout :10000,
                maximumAge : 10000
            });
        }
    }
</script>

</body>
</html>

猜你喜欢

转载自my.oschina.net/swmhxhs/blog/1825154