高德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);
     
     }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM