日期:2014-05-16  浏览次数:20325 次

为什么我这js代码显示数组的顺序每次都不同?
Java code

<script type="text/javascript">
gpsxy = function (){
var points = [
new BMap.Point(116.397428,39.90923),
new BMap.Point(116.396428,39.90923),
new BMap.Point(116.395428,39.90923),
new BMap.Point(116.394428,39.90923),
new BMap.Point(116.393428,39.90923),
new BMap.Point(116.392428,39.90923),
new BMap.Point(116.391428,39.90923),
new BMap.Point(116.390428,39.90923),
new BMap.Point(116.38928,39.90923),
new BMap.Point(116.388428,39.90923),
             ];
for (i=0;i<=9;i++){
    BMap.Convertor.translate(points[i],0,translateCallback);
}
}
translateCallback = function (point){
   document.getElementById("baiduXY").innerHTML = document.getElementById("baiduXY").innerHTML+ Math.round(point.lng*100000)/100000 + "," + Math.round(point.lat*100000)/100000+"<br>";
}
</script>


执行后获得10个点,然后F5刷新页面再执行获得的10个点的排序和之前不一样

------解决方案--------------------
translate 函数执行的时间不一样。
回调函数的执行顺序没发控制


全部同步执行,才能按你的指定顺序执行
------解决方案--------------------
探讨

translate 函数执行的时间不一样。
回调函数的执行顺序没发控制


全部同步执行,才能按你的指定顺序执行

------解决方案--------------------
探讨
translate 函数执行的时间不一样。
回调函数的执行顺序没发控制


全部同步执行,才能按你的指定顺序执行