gpt4 book ai didi

javascript - 如何获得用户当前位置的最大准确性

转载 作者:行者123 更新时间:2023-12-02 19:32:35 25 4
gpt4 key购买 nike

我正在使用此代码来获取准确的用户位置...

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com