var result = []; var num = 0; var sum = xList.length; //坐标转换完之后的回调函数 tranCallback = function (point) { result.push(point.points[0]); //一个个点转换的过程中记录已转换点的个数 num++; if (num == sum) { drawPolyline(); //在最后一次画线 } else { makeLine(); //循环坐标转换,并不画线 } } function makeLine() { var gpsPoint = new BMap.Point(xList[num], yList[num]); var convertor = new BMap.Convertor(); var pointArr = []; pointArr.push(gpsPoint); convertor.translate(pointArr, 1, 5, tranCallback); } setTimeout(function () { makeLine(); }, 1000);
原文:http://www.cnblogs.com/andies/p/5209463.html