百度地圖路書 使用 軌跡全局觀看

       //引入百度  api   ak是你百度控制臺(tái)申請(qǐng)的key
      http://api.map.baidu.com/api?v=1.0&type=webgl&ak=${ak}&callback=init
    // 引入百度路書 api
      http://api.map.baidu.com/library/LuShu/gl/src/LuShu_min.js
    var styleOptions = {
                 strokeColor: '#5E87DB', // 邊線顏色
                  fillColor: '#5E87DB', // 填充顏色。當(dāng)參數(shù)為空時(shí),圓形沒有填充顏色
                  strokeWeight: 2, // 邊線寬度,以像素為單位
                 strokeOpacity: 1, // 邊線透明度,取值范圍0-1
                 fillOpacity: 0.1 // 填充透明度,取值范圍0-1
     };
    TrackAnimation(type, data,n) {  
        let that=this
        let styleOption = Object.assign({}, styleOptions);
        let icon=null
        // styleOption.strokeStyle = "dashed"
        styleOption.strokeColor = "#2D72DB"
        styleOption.strokeWeight = 4
        var point = [];
    
        for (var i = 0; i < data.length; i++) {
            if(data[i].lon&&data[i].lat){
                point.push(new BMapGL.Point(data[i].lon, data[i].lat));
                    
            }
            
        }
        if(type=='人員軌跡'){
            icon=require('../../../../assets/img/map/14814.png')
        }else{
            icon=require('../../../../assets/img/map/14813.png')
        }
    var polyline = new BMapGL.Polyline(point,styleOption);
        this.map.addOverlay(polyline);
        this.polyline=polyline
        this.map.setViewport(point)  //  自動(dòng)調(diào)整軌跡視野
            // 路書     
            let lushu = new BMapGLLib.LuShu(this.map, polyline.getPath(), {
                geodesic: true,
                autoCenter: false,//自動(dòng)調(diào)整路線視野
                icon: new BMapGL.Icon(icon, new BMapGL.Size(30, 30), { anchor: new BMapGL.Size(15, 15) }),
                speed: n,    //  速度
                enableRotation: false    //   圖標(biāo)隨著道路走向旋轉(zhuǎn)
            });
            console.log(lushu)
            
            this.lushu=lushu
            setTimeout(function(){
                    that.mapZoomOut()  
                    lushu.stop()
                lushu.start()
             
            },500)
              
    },
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容