我正在使用此代码来获取准确的用户位置...
watchID=navigator.geolocation.watchPosition(handleGetCurrentPosition, handleGetCurrentPositionError, {enableHighAccuracy:true});
function handleGetCurrentPosition(location)
{
document.getElementById("lat").value = location.coords.latitude;
document.getElementById("lon").value = location.coords.longitude;
document.getElementById("accu").value =location.coords.accuracy;
document.forms["myform"].submit();
}
function handleGetCurrentPositionError(){
alert("Location could not be found.")
}
bt 我得到的结果不准确。 我使用的代码有什么问题吗?
最佳答案
准确性取决于您的地理定位
设备的功能。 navigator.geolocation
只是一个与该设备配合使用的 API
。如果设备不支持高精度,您将无法使用它执行任何操作。
关于javascript - 如何获得用户当前位置的最大准确性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11327083/