|
|
|
|
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
|
|
|
|
declare var AMap: any;
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-router-gis',
|
|
|
|
|
templateUrl: './router-gis.component.html',
|
|
|
|
|
styleUrls: ['./router-gis.component.scss']
|
|
|
|
|
})
|
|
|
|
|
export class RouterGISComponent implements OnInit {
|
|
|
|
|
@Output() onCustomEvent: EventEmitter<any> = new EventEmitter();//创建实力
|
|
|
|
|
constructor() { }
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
|
window.setTimeout(()=>{
|
|
|
|
|
this.mapInit()
|
|
|
|
|
},0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngAfterViewInit(): void {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//地图初始化
|
|
|
|
|
mapInit () {
|
|
|
|
|
console.log("ditu")
|
|
|
|
|
//创建地图
|
|
|
|
|
let map = new AMap.Map('center', {
|
|
|
|
|
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:'山东'}], //路线可搜索, 可用坐标
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//下一步
|
|
|
|
|
next(){
|
|
|
|
|
this.emitEvent()
|
|
|
|
|
}
|
|
|
|
|
private emitEvent(){
|
|
|
|
|
this.onCustomEvent.emit('data from child');//通过emit可将需要传递的数据发送给父组件
|
|
|
|
|
}
|
|
|
|
|
//取消
|
|
|
|
|
back(){
|
|
|
|
|
window.history.back();
|
|
|
|
|
}
|
|
|
|
|
}
|