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>