From 2d0b00024271e6bc0b606d2fd3c3bc25767c5399 Mon Sep 17 00:00:00 2001 From: Taric Xin Date: Wed, 9 Mar 2022 14:40:57 +0800 Subject: [PATCH] edit --- .../vehicle-detail.component.ts | 2 +- .../account-detail.component.ts | 2 +- .../amap-path-simplifier.component.ts | 125 +++++++++++++++++- 3 files changed, 125 insertions(+), 4 deletions(-) diff --git a/src/app/routes/order-management/components/vehicle-detail/vehicle-detail.component.ts b/src/app/routes/order-management/components/vehicle-detail/vehicle-detail.component.ts index 73f75c21..d9110498 100644 --- a/src/app/routes/order-management/components/vehicle-detail/vehicle-detail.component.ts +++ b/src/app/routes/order-management/components/vehicle-detail/vehicle-detail.component.ts @@ -135,7 +135,7 @@ export class OrderManagementVehicleDetailComponent implements OnInit { let list :any[] = []; points?.forEach((item: any) => { list.push({ - name: item.hgt, + name: `${item.spd}km/h`, lnglat: [Number((Number(item.lon) / 600000).toFixed(6)), Number((Number(item.lat) / 600000).toFixed(6))] }); }); diff --git a/src/app/shared/components/account-detail/account-detail.component.ts b/src/app/shared/components/account-detail/account-detail.component.ts index e81ea5fe..a0b1a133 100644 --- a/src/app/shared/components/account-detail/account-detail.component.ts +++ b/src/app/shared/components/account-detail/account-detail.component.ts @@ -24,7 +24,7 @@ export class AccountDetailComponent implements OnInit { ngOnInit(): void {} createAccount(item: any, type: '1' | '2') { - if (item.pfAccount) { + if ((type === '1' && item.paAccount) || (type === '2' && item.pfAccount)) { return; } const params = { diff --git a/src/app/shared/components/amap/amap-path-simplifier/amap-path-simplifier.component.ts b/src/app/shared/components/amap/amap-path-simplifier/amap-path-simplifier.component.ts index 66c13d4b..6071a0b7 100644 --- a/src/app/shared/components/amap/amap-path-simplifier/amap-path-simplifier.component.ts +++ b/src/app/shared/components/amap/amap-path-simplifier/amap-path-simplifier.component.ts @@ -30,6 +30,42 @@ export class AmapPathSimplifierComponent implements OnInit, OnChanges { @Output() clcikPointEvent = new EventEmitter(); + @Input() + pois: any = [ + { + id: 'A', + position: [116.020764, 39.904989], + markerLabel: 'X_A', + infoWinContent: 'Hello! A', + listDesc: '起', + color: '#F5222D' + }, + { + id: 'B', + position: [116.405285, 39.904989], + markerLabel: 'X_B', + infoWinContent: 'Hello! B', + listDesc: '终', + color: '#1890ff' + }, + { + id: 'C', + position: [116.789806, 39.904989], + markerLabel: 'X_C', + infoWinContent: 'Hello! C', + listDesc: '卸', + color: '#1890ff' + }, + { + id: 'C', + position: [116.789806, 39.904989], + markerLabel: 'X_C', + infoWinContent: 'Hello! C', + listDesc: '装', + color: '#F5222D' + } + ]; + constructor(public service: BaseService) {} ngOnChanges(changes: SimpleChanges): void { if (changes?.pathList?.currentValue && this?.pathSimplifierIns) { @@ -79,6 +115,7 @@ export class AmapPathSimplifierComponent implements OnInit, OnChanges { // this.service.msgSrv.info('地图加载完成 !'); this.pathInit(); // this.setPOIS(); + // this.loadPOIS(); }); }) .catch(e => { @@ -86,6 +123,88 @@ export class AmapPathSimplifierComponent implements OnInit, OnChanges { }); } + loadPOIS() { + AMapUI.loadUI(['overlay/SvgMarker'], (SvgMarker: any) => { + if (!SvgMarker.supportSvg) { + //当前环境并不支持SVG,此时SvgMarker会回退到父类,即SimpleMarker + alert('当前环境不支持SVG'); + } + + //just some colors + var colors = ['#F5222D', '#1890ff']; + + //SvgMarker.Shape下的Shape + var shapeKeys = ['WaterDrop']; + + var colNum = 2, + rowNum = shapeKeys.length; + const markers: any[] = []; + + this.pois.forEach((d: any) => { + //创建shape + const shape = new SvgMarker.Shape['WaterDrop']({ + height: 40, + strokeWidth: 1, + strokeColor: '#ccc', + fillColor: '#F5222D' + }); + + markers.push( + new SvgMarker(shape, { + map: this.aMap, + position: d.position, + containerClassNames: 'shape-' + 'WaterDrop', + iconLabel: { + innerHTML: d.listDesc, + style: { + top: 7 + 'px' + } + }, + showPositionPoint: true + }) + ); + }); + console.log(markers); + + // var pxCenter = this.aMap.lnglatToPixel(this.aMap.getCenter()); + + // var startX = pxCenter.getX(), + // startY = pxCenter.getY(); + + // for (var c = 0; c < colNum; c++) { + // for (var r = 0; r < rowNum; r++) { + // var idx = r * colNum + c; + + // if (!colors[idx]) { + // continue; + // } + + // var x = startX + (c - colNum / 2) * 70; + // var y = startY + 50 + (r - rowNum / 2) * 80; + + // var labelCenter = shape.getCenter(); + + // var position = this.aMap.pixelToLngLat(new AMap.Pixel(x, y)); + + // markers.push( + // new SvgMarker(shape, { + // map: this.aMap, + // position: position, + // containerClassNames: 'shape-' + shapeKeys[r], + // iconLabel: { + // innerHTML: String.fromCharCode('A'.charCodeAt(0) + c), + // style: { + // top: labelCenter[1] - 9 + 'px' + // } + // }, + // showPositionPoint: true + // }) + // ); + // } + // } + }); + } + pathInit() { this.pathSimplifierIns = new AMapUI.PathSimplifier({ zIndex: 100, @@ -103,6 +222,8 @@ export class AmapPathSimplifierComponent implements OnInit, OnChanges { return lnglatList; }, getHoverTitle: function (pathData: any, pathIndex: any, pointIndex: any) { + console.log(pathData, pointIndex); + if (pointIndex >= 0) { //point return pathData.name + ',' + pathData.points[pointIndex].name; @@ -143,7 +264,7 @@ export class AmapPathSimplifierComponent implements OnInit, OnChanges { //返回数据项的位置信息,需要是AMap.LngLat实例,或者是经纬度数组,比如[116.789806, 39.904989] getPosition: (dataItem: any) => { console.log(dataItem); - + return dataItem.position; }, //返回数据项对应的Marker @@ -256,7 +377,7 @@ export class AmapPathSimplifierComponent implements OnInit, OnChanges { setPathIndex(index: number) { this.pathSimplifierIns.setSelectedPathIndex(index); - this.startNav(); + // this.startNav(); } startNav() {