edit
This commit is contained in:
@ -16,13 +16,14 @@ const CONFIG = amapConf;
|
||||
export class AmapPathSimplifierComponent implements OnInit, OnChanges {
|
||||
aMap: any;
|
||||
pathSimplifierIns: any;
|
||||
navigator: any;
|
||||
@Input()
|
||||
pathList: any = [];
|
||||
@Input()
|
||||
selectedIndex = 0;
|
||||
@Input()
|
||||
mapWidth = '800px';
|
||||
@Input('MapList') MapList: any;
|
||||
@Input() MapList: any;
|
||||
@Input()
|
||||
mapHeight = '500px';
|
||||
|
||||
@ -35,15 +36,19 @@ export class AmapPathSimplifierComponent implements OnInit, OnChanges {
|
||||
this.setData(changes.pathList?.currentValue);
|
||||
this.setPathIndex(this.selectedIndex);
|
||||
}
|
||||
if (changes?.MapList?.currentValue && this?.pathSimplifierIns) {
|
||||
this.pathList = [
|
||||
{
|
||||
name: '路线1',
|
||||
points: changes?.MapList?.currentValue
|
||||
}
|
||||
];
|
||||
this.setData(this.pathList);
|
||||
this.setPathIndex(this.selectedIndex);
|
||||
}
|
||||
}
|
||||
ngOnInit(): void {
|
||||
this.mapInit();
|
||||
this.pathList = [
|
||||
{
|
||||
name: '路线1',
|
||||
points: this.MapList
|
||||
}
|
||||
];
|
||||
// this.DataInit();
|
||||
}
|
||||
ngOnDestroy(): void {
|
||||
@ -104,26 +109,20 @@ export class AmapPathSimplifierComponent implements OnInit, OnChanges {
|
||||
return pathData.name + ',点数量' + pathData.points?.length;
|
||||
},
|
||||
renderOptions: {
|
||||
renderAllPointsIfNumberBelow: 100 //绘制路线节点,如不需要可设置为-1
|
||||
renderAllPointsIfNumberBelow: 10 //绘制路线节点,如不需要可设置为-1
|
||||
}
|
||||
});
|
||||
(window as any).pathSimplifierIns = this.pathSimplifierIns;
|
||||
this.setData(this.pathList);
|
||||
|
||||
if(this.pathList.length>0){
|
||||
this.setPathIndex(this.selectedIndex);
|
||||
if (this.pathList.length > 0) {
|
||||
this.setPathIndex(this.selectedIndex);
|
||||
}
|
||||
|
||||
this.pathSimplifierIns.on('pointClick', (e: any, info: any) => {
|
||||
this.clcikPointEvent.emit({ e, info });
|
||||
console.log('Click: ' + info.pathData.points[info.pointIndex].name);
|
||||
});
|
||||
// navg1.start();
|
||||
// var navg1 = this.pathSimplifierIns.createPathNavigator(0, {
|
||||
// loop: true, //循环播放
|
||||
// speed: 1000000 //巡航速度,单位千米/小时
|
||||
// });
|
||||
// navg1.start();
|
||||
}
|
||||
|
||||
setData(pathList: Array<any>) {
|
||||
@ -132,5 +131,18 @@ export class AmapPathSimplifierComponent implements OnInit, OnChanges {
|
||||
|
||||
setPathIndex(index: number) {
|
||||
this.pathSimplifierIns.setSelectedPathIndex(index);
|
||||
this.startNav();
|
||||
}
|
||||
|
||||
startNav() {
|
||||
if (this.navigator) {
|
||||
this.navigator.start();
|
||||
} else {
|
||||
this.navigator = this.pathSimplifierIns?.createPathNavigator(0, {
|
||||
loop: true, //循环播放
|
||||
speed: 1000000 //巡航速度,单位千米/小时
|
||||
});
|
||||
this.navigator?.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user