<script>
var options = {enableHighAccuracy: true, timeout: 5000, maximumAge: 0};
function success(pos) {
var crd = pos.coords;
document.getElementById("id_longitude").parentNode.append('自动获取当前设备经度坐标:'+(crd.longitude))
document.getElementById("id_latitude").parentNode.append('自动获取当前设备维度坐标:'+(crd.latitude))
{#document.getElementById("id_longitude").value=crd.longitude;#}
{#document.getElementById("id_latitude").value=crd.latitude;#}
{#console.log(crd.longitude);#}
{#console.log(crd.latitude);#}
{#console.log(`误差:${crd.accuracy} 米`);#}
}
function error(err) {
console.warn(`ERROR(${err.code}): ${err.message}`);
}
navigator.geolocation.getCurrentPosition(success, error, options);
</script>
HTML5获取坐标
最新推荐文章于 2023-09-30 20:24:54 发布