import { Component, OnInit } from '@angular/core'; declare var AMap: any; @Component({ selector: 'app-water-road', templateUrl: './water-road.component.html', styleUrls: ['./water-road.component.scss'] }) export class WaterRoadComponent implements OnInit { constructor() { } ngOnInit(): void { } ngAfterViewInit(): void { window.setTimeout(()=>{ this.mapInit() },0) } //地图初始化 mapInit () { //创建地图 let map = new AMap.Map('map', { resizeEnable: true, cursor: 'default', zooms:[6,18], }); // //构造路线导航类 实际路线 // let driving = new AMap.Driving({ // map: map, // showTraffic: true, // isOutline: true, // }); // driving.search( [{keyword: '广西消防总队',city:'广西'},{keyword: '万科公园里',city:'广西'},{keyword: '南宁明安医院',city:'广西'}], ); // //构造路线导航类 导航路线 // let drivingTwo = new AMap.Driving({ // map: map, // showTraffic: false, // }); // drivingTwo.search( [{keyword: '广西消防总队',city:'广西'},{keyword: '南宁明安医院',city:'广西'}], ); //function (status,result) { console.log(status,result) } //地图路线 匹配起始点回调函数 //new AMap.LngLat(116.379028, 39.865042), new AMap.LngLat(116.427281, 39.903719) / [{keyword: '淄博站',city:'山东'},{keyword: '淄博北站',city:'山东'}], //路线可搜索, 可用坐标 } }