有这样一个加载百度地图的fuction,,,(其他的无关紧要的就不写了,因为整个网页功能上是正确的,,自己感觉是没有影响,,)
function loadXMLDoc()
{var xmlhttp;
var xx,xy,x,i,id,title;
var txt;
if (window.XMLHttpRequest)
{xmlhttp=new XMLHttpRequest();
}
else
{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
。。。。。。。。。
var opts = {
position : point, // 指定文本标注所在的地理位置
offset : new BMap.Size(30, -30) //设置文本偏移量
}
function openInfo(content,e){
var p = e.target;
var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
var infoWindow = new BMap.InfoWindow(content,opts); // 创建信息窗口对象
map.openInfoWindow(infoWindow,point); //开启信息窗口
}
map.clearOverlays();
for (i=0;i<x.length;i++)
{
xx=x[i].getElementsByTagName("x");
xy=x[i].getElementsByTagName("y");
id=x[i].getElementsByTagName("id");
。。。。。。。。。。。。
}
然后问题来了,这是我刷新的
function refresh(){
loadXMLDoc(); //坐标点有变,位置需要不断从xml中读
setInterval(refresh,10000);
}
refresh();
然后这个html撑不过1分钟就要崩溃,,,,怎么办,在loadXMLDoc中有map.clearOverlays(); ,可是还是崩溃,,,
setInterval:
The real delay between func calls for setInterval is less than in the code!
That’s normal, because the time taken by func’s execution “consumes” a part of the interval.
It is possible that func’s execution turns out to be longer than we expected and takes more than 100ms.
In this case the engine waits for func to complete, then checks the scheduler and if the time is up, runs it again immediately.
In the edge case, if the function always executes longer than delay ms, then the calls will happen without a pause at all.
setTimeout:
The recursive setTimeout guarantees the fixed delay (here 100ms).
That’s because a new call is planned at the end of the previous one.
举例: