高德js API moveAlong 函數的一個錯誤解決

 

    使用覆蓋物之一:點標記,讓點標記沿着固定的路線移動。

   API 提供了現成的函數 moveAlong()

  開始以爲 實現移動很簡單:分兩部 1.準備好經緯度數組 2.調用moveAlong()函數。按照這個思路做的話出現位置錯誤:a.Ga is not a function , 這個問題研究了半天,最後解決了: 單純給出經緯度數組是不行的,還要生成路徑。

 

moveAlong(lnglatlist:Array,speed:Number,f:Function,circlable:Boolean)

 

lnglatlist 需要生成折線。

 

仔細想想也是 如果只給出一堆點的話,是不能確定移動軌跡的。必鬚生成了折線,纔是固定的路徑。

 

var lineFour = [[,],[,],[,],
   [,],[,],[,],
   [,],[,],[,],[,]
   ];    

    var polylineFour = new AMap.Polyline({
            map: map,
            path: lineFour,
            strokeColor: "#00A",  //線顏色
            strokeOpacity: 1,     //線透明度
            strokeWeight: 3,      //線寬
            strokeStyle: "solid"  //線樣式
        });
        markerFour = new AMap.Marker({
                title:'0004',
                icon:'http://webapi.amap.com/images/car.png',
                position:[15.534894,38.898715],
                offset:new AMap.Pixel(-26, -13),
                autoRotation: true  //自動旋轉
                 });
                 markerFour.setMap(map);
                 polylineFour.hide();
                 markerFour.moveAlong(lineFour,100);
     
     }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章