我有这个问题,我有4个变量用GPS坐标初始化,一旦加载,我必须在另一个脚本。 前两个是立即加载,另外两个是4秒后加载,如下所示:
take 6 xs
= take 6 xs where xs=1:next xs -- next looks 1 element back
= 1:take 5 xs1 where xs=1:xs1; xs1=next xs
= 1:take 5 xs1 where xs1=2:10:next xs1 -- 2 elements back
= 1:2:take 4 xs2 where xs1=2:xs2; xs2=10:next xs1
= 1:2:10:take 3 xs3 where xs1=2:xs2; xs2=10:xs3; xs3=next xs1
= 1:2:10:take 3 xs3 where xs2=10:xs3; xs3=3:20:next xs2 -- 3 elements
= 1:2:10:3:take 2 xs4 where xs2=10:xs3; xs3=3:xs4; xs4=20:next xs2
= 1:2:10:3:20:take 1 xs5 where xs2=10:xs3; xs3=3:xs4; xs4=20:xs5; xs5=next xs2
= 1:2:10:3:20:take 1 xs5 where xs3=3:xs4; xs4=20:xs5; xs5=11:100:next xs3 -- 4
....
如果您知道如何创建条件'如果'这样做(例如:当所有坐标变量都初始化时,执行此操作)?因为GPS总是加载不同的时间而且速度很慢 感谢。
某事,我试过
(function(){
function onSuccess(position) {
poslat = position.coords.latitude;
poslon = position.coords.longitude;
console.log('latitudine1 ' + poslat);
console.log('longitudine1 ' + poslon);
//after 4 second
setTimeout(function(){
poslt = position.coords.latitude;
posln = position.coords.longitude;
speed = position.coords.speed;
alt = position.coords.altitudeAccuracy;
precisione = position.coords.accuracy;
document.getElementById("altitudine").innerHTML = alt;
document.getElementById("precision").innerHTML = precisione;
var speedfix = speed * 3.6;
var speedfixed = speedfix.toFixed(3);
document.getElementById("sped").innerHTML = speedfixed;
console.log('latitudine2 ' + poslt);
console.log('longitudine2 ' + posln);
//alert("Passed 4 second");
},4000);
答案 0 :(得分:0)
此代码适用于wi-fi / 3g连接。
if ((poslat != null) && (poslon != null) && (poslt != null) && (posln != null))
{
ready();
}else{
alert('GPS / Connessione debole.. ')
}
但是当我尝试只使用GPS(没有信号)时不起作用。 为什么?我认为当GPS加载时,变量没有值“null” 但是哪个??