leaflet动态添加路线–L.Polyline.AntPath

 1. 下载leaflet-ant-path依赖包

npm install leaflet-ant-path

 2. 在项目中引用此js文件

"src/assets/js/ant-path/leaflet-ant-path.js",

 3. 在js中写入调用即可



//循环获取经纬度  
const latlngs = data.map(e => {
        return L.latLng(e.Lat, e.Lon);
      });

  //根据经纬度规划动态路线
  let antPolyline = new L.Polyline.AntPath(latlngs, {
        paused: false,
        delay: 400
  });

  //把动态路线添加到地图上
  antPolyline.addTo(map)
  
}

 

转载自:https://blog.csdn.net/qq_34790644/article/details/84070590

You may also like...

退出移动版