edit
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
import AMapLoader from '@amap/amap-jsapi-loader';
|
||||
import { Component, Input, OnChanges, OnInit, Output, SimpleChanges, EventEmitter, OnDestroy } from '@angular/core';
|
||||
import { amapConf } from '@conf/amap.config';
|
||||
import { InputNumber } from '@delon/util';
|
||||
import { throwError } from 'rxjs';
|
||||
import { BaseService } from 'src/app/shared/services';
|
||||
import { InfoItem, MapList, PathList, POI } from '../amap.service';
|
||||
import { AmapService, InfoItem, MapList, PathList, POI } from '../amap.service';
|
||||
declare var AMap: any;
|
||||
declare var AMapUI: any;
|
||||
declare var Loca: any;
|
||||
@ -31,6 +32,9 @@ export class AmapPathSimplifierComponent implements OnInit, OnChanges, OnDestroy
|
||||
// 当前选中路线图下标
|
||||
@Input()
|
||||
selectedIndex = 0;
|
||||
// 巡航倍数
|
||||
@InputNumber()
|
||||
navSpeed = 1;
|
||||
// 标点数组
|
||||
@Input()
|
||||
pois: POI[] = [];
|
||||
@ -44,7 +48,7 @@ export class AmapPathSimplifierComponent implements OnInit, OnChanges, OnDestroy
|
||||
@Output()
|
||||
readonly clcikPointEvent = new EventEmitter<any>();
|
||||
|
||||
constructor(public service: BaseService) {}
|
||||
constructor(public service: BaseService, private amapService: AmapService) {}
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
// 路线图变更: 设置路线图, 指定路线图
|
||||
if (changes?.pathList?.currentValue && this?.pathSimplifierIns) {
|
||||
@ -154,7 +158,8 @@ export class AmapPathSimplifierComponent implements OnInit, OnChanges, OnDestroy
|
||||
position: info.pathData.points[info.pointIndex].lnglat,
|
||||
content: `
|
||||
<label style="font-weight: bold;">${result.regeocode.formattedAddress}<label/><br/>
|
||||
<label style="font-weight: 400;">车速: ${info.pathData.points[info.pointIndex].name}<label/>
|
||||
<label style="font-weight: 400;">车速: ${info.pathData.points[info.pointIndex].name}<label/><br/>
|
||||
<label style="font-weight: 400;">时间: ${this.amapService.formatTime(info.pathData.points[info.pointIndex].time)}<label/>
|
||||
`
|
||||
});
|
||||
}
|
||||
@ -234,14 +239,32 @@ export class AmapPathSimplifierComponent implements OnInit, OnChanges, OnDestroy
|
||||
* 开启巡航
|
||||
*/
|
||||
startNav() {
|
||||
if (this.navigator) {
|
||||
this.navigator.start();
|
||||
this.navigator = this.pathSimplifierIns?.createPathNavigator(this.selectedIndex, {
|
||||
loop: true, //循环播放
|
||||
speed: 500000 * this.navSpeed //巡航速度,单位千米/小时
|
||||
});
|
||||
this.navigator?.start();
|
||||
}
|
||||
|
||||
changeMultiple(multiple: number) {
|
||||
if (multiple <= 0) {
|
||||
this.navSpeed = 1;
|
||||
return;
|
||||
} else {
|
||||
this.navigator = this.pathSimplifierIns?.createPathNavigator(0, {
|
||||
loop: true, //循环播放
|
||||
speed: 1000000 //巡航速度,单位千米/小时
|
||||
});
|
||||
this.navigator?.start();
|
||||
this.navSpeed = multiple;
|
||||
this.resetNav();
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置巡航 */
|
||||
resetNav() {
|
||||
if (this.navigator) {
|
||||
this.navigator.destroy();
|
||||
setTimeout(() => {
|
||||
this.startNav();
|
||||
}, 200);
|
||||
} else {
|
||||
this.startNav();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user