diff --git a/src/views/counter/map2.vue b/src/views/counter/map2.vue index f01f8a6..c40e88a 100644 --- a/src/views/counter/map2.vue +++ b/src/views/counter/map2.vue @@ -169,12 +169,6 @@ export default { resizeEnable: true, zoom: 13 }) - // new AMap.Marker({ - // position: this.coordinate, - // zIndex: 10, - // title: this.deviceList[0].title, - // map: map - // }) const drivingOptions = { map: map, // city: '中山市', @@ -182,16 +176,21 @@ export default { // cityd:'乌鲁木齐', // policy: AMap.DrivingPolicy.LEAST_TIME } - const driving = new AMap.Driving(drivingOptions) const button = document.getElementById('bt') - driving.search(new AMap.LngLat(113.344095, 22.673091), new AMap.LngLat(113.203460828994, 22.64902452257), (status, result) => { - button.onclick = () => { - driving.searchOnAMAP({ - origin: result.origin, - destination: result.destination - }) - } + AMap.plugin(['AMap.ToolBar', 'AMap.Scale', 'AMap.Driving'], () => { + map.addControl(new AMap.ToolBar()) + map.addControl(new AMap.Scale()) + const driving = new AMap.Driving(drivingOptions) + driving.search(new AMap.LngLat(113.344095, 22.673091), new AMap.LngLat(113.203460828994, 22.64902452257), (status, result) => { + button.onclick = () => { + driving.searchOnAMAP({ + origin: result.origin, + destination: result.destination + }) + } + }) }) + // const driving = new AMap.Driving(drivingOptions) this.flag = true // if (AMap.UA.mobile) { // document.getElementById('panel').style.display = 'none'