路书 百度地图参考文档
https://dafrok.github.io/vue-baidu-map/#/zh/bmaplib/lushu
(误人子弟)
<template>
<baidu-map class="map" :center="{lng: 116.404, lat: 39.915}" :zoom="11">
<bm-driving start="天安门" end="百度大厦" @searchcomplete="handleSearchComplete" :panel="false" :autoViewport="true"></bm-driving>
//显示小车组件
<bml-lushu
@stop="reset"
:path="path"
:icon="icon"
:play="play"
:rotation="true">
</bml-lushu>
//显示小车走的路径
<bm-polyline v-if="path && path.length > 0" :path="path" stroke-color="#0000FF" :editing="false"></bm-polyline>
</baidu-map>
</template>
<script>
import {BmlLushu} from 'vue-baidu-map'
export default {
components: {
BmlLushu
},
data () {
return {
play: true,
path: [],
icon: {
url: 'http://api.map.baidu.com/library/LuShu/1.2/examples/car.png',
size: {width: 52, height: 26},
opts: {anchor: {width: 27, height:13}}
}
}
},
methods: {
reset () {
this.play = false
},
handleSearchComplete (res) {
this.path = res.getPlan(0).getRoute(0).getPath()
}
}
}
</script>