赞
踩
代码:
<script> import 'echarts/extension/bmap/bmap' export default { data() { return {} }, methods: { drawLine() { let map = new BMap.Map("container",{enableMapClick: false}); map.centerAndZoom(new BMap.Point(113.274, 23.135), 14); // 设置中心点(广州) map.clearOverlays(); // 清除地图上的覆盖物 let start = new BMap.Point(this.entities[0].longitudeFix,this.entities[0].latitudeFix); // 起始点 let end = new BMap.Point(this.entities[1].longitudeFix,this.entities[1].latitudeFix); // 终点 let time = ""; let lenth = ""; let searchComplete = function (results){ if (transit.getStatus() != BMAP_STATUS_SUCCESS){ return ;} // 检测返回状态 let plan = results.getPlan(0); time = plan.getDuration(true) + "\n"; //获取时间 lenth = plan.getDistance(true); //获取距离 }; let transit = new BMap.DrivingRoute(map, {renderOptions: {map: map}, onSearchComplete: searchComplete, onPolylinesSet: function(){ setTimeout(function(){},10); } }); transit.search(start, end); } } } </script>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。