Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Geolocation 地理位置监视位置更新缓慢_Geolocation - Fatal编程技术网

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=方向;
}