以下是百度地图提供的功能 批量坐标转换function callback(xyResults){
 var xyResult = null;
 for(var index in xyResults){
  xyResult = xyResults[index];
  if(xyResult.error != 0){continue;}//出错就直接返回;
  var point = new BMap.Point(xyResult.x, xyResult.y);
     var er = new BMap.Marker(point);
     map.addOverlay(er);
     map.setCenter(point);// 由于写了这句,每一个被设置的点都是中心点的过程
    }
}
setTimeout(function(){
    BMap.Convertor.transMore(points,0,callback);        //一秒之后开始进行坐标转换。参数2,表示是从GCJ-02坐标到百度坐标。参数0,表示是从GPS到百度坐标
}, 1000);然后百度有限制,一秒钟只能转换50个坐标, 如果这个里面有140个坐标需要转换.
会分三次去执行,
比如0-49 为第一次发出去的 50-99为第二次发出去的,剩下的第三次发送出去。
function callback(xyResults){ 这个函数不是按顺序返回 可以最选返回的是第三次发送的
然后返回第一次发送的,然后再是第一次发送的,请问有没有办法解决这个问题。

解决方案 »

  1.   

    无非就是ajax呗,callback是ajax成功后的回调这样想就简单了啊,在callback里面执行下一次的发送工作。写的丑一点就是var i = 0,point = [1,2,3,4,5],step=2;//定义起始点i,point为坐标数组,step每次发送个数
    function callback(xyResults){
     var xyResult = null;
     for(var index in xyResults){
      xyResult = xyResults[index];
      if(xyResult.error != 0){continue;}//出错就直接返回;
      var point = new BMap.Point(xyResult.x, xyResult.y);
         var er = new BMap.Marker(point);
         map.addOverlay(er);
         map.setCenter(point);// 由于写了这句,每一个被设置的点都是中心点的过程
        }
        i = i + step;
        if(i>point.length){//超过数量则直接return
            return;
        }
        var points = point.slice(i,i+step);//取出本次要发送的坐标数组
        BMap.Convertor.transMore(points,0,callback)
    }
    var points = point.slice(i,step);取出第一次要发送的坐标数组
    BMap.Convertor.transMore(points,0,callback);
      

  2.   

    谢谢。思路我想到了,
    就是不会分割数据,郁闷啊。
    谢谢point.slice