Geolocation 地理位置监视位置更新缓慢
来自Geolocation 地理位置监视位置更新缓慢,geolocation,Geolocation,来自geolocation.watchPosition的onSuccess例程每秒更新一次是否正常,即使maximumAge设置为0 我发现如下情况: compass.watchHeading中的onSuccess值每0,1秒更新一次,并显示在div中。当从geolocation.watchPosition调用onSuccess例程中的document.getElementById中的onSuccess值并将其显示在附近的div中时,我看到该值似乎每秒都在缓慢更新 我需要在位置结果中使用标题值,
geolocation.watchPosition
的onSuccess例程每秒更新一次是否正常,即使maximumAge
设置为0
我发现如下情况:
compass.watchHeading
中的onSuccess值每0,1秒更新一次,并显示在div中。当从geolocation.watchPosition
调用onSuccess例程中的document.getElementById
中的onSuccess值并将其显示在附近的div中时,我看到该值似乎每秒都在缓慢更新
我需要在位置结果中使用标题值,这就是我注意到的原因
要使其可见,请执行以下操作:
function onSuccess1(heading) {
direction = Math.round(heading.magneticHeading);
// Debug info
document.getElementById('heading').innerHTML = direction;
}
function onSuccess2(position) {
positionLat = position.coords.latitude;
positionLong = position.coords.longitude;
var direction = document.getElementById('heading').innerHTML;
// Debug info
document.getElementById('headingControle').innerHTML = direction;
}
<div id = "debug">
<span id = "heading"></span><span id = "headingControle"></span>
</div>
函数onSuccess1(标题){
方向=数学圆(航向磁导航);
//调试信息
document.getElementById('heading')。innerHTML=方向;
}
函数onSuccess2(位置){
positionLat=位置坐标纬度;
positionLong=位置坐标经度;
var direction=document.getElementById('heading').innerHTML;
//调试信息
document.getElementById('headingControle')。innerHTML=方向;
}