From 034eb48a67572238c4440666361fbe60ed7b87eb Mon Sep 17 00:00:00 2001 From: anxinCPF <1105965053@qq.com> Date: Sun, 27 Jun 2021 15:29:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=9A=E5=90=88=E7=89=A9=E5=88=9D=E6=AD=A5?= =?UTF-8?q?=E6=99=9A=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fire-force/fire-force.component.ts | 6 ++-- .../linkage-forces.component.ts | 2 +- .../water-collection.component.ts | 2 +- .../gis-labeling/gis-labeling.component.ts | 4 +-- .../water-road/water-road.component.ts | 2 +- src/modules/map/declare/keda-map.ts | 35 ++++++++++++++++--- src/modules/map/declare/map.d.ts | 11 +++++- 7 files changed, 48 insertions(+), 14 deletions(-) diff --git a/src/app/data-collection/fire-force/fire-force.component.ts b/src/app/data-collection/fire-force/fire-force.component.ts index 8536a72..afde672 100644 --- a/src/app/data-collection/fire-force/fire-force.component.ts +++ b/src/app/data-collection/fire-force/fire-force.component.ts @@ -7,7 +7,7 @@ import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dial import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; import { MapFactory } from '@src/modules/map/declare/factory'; -import { IMap, IMarker, IPlaceSearch } from '@src/modules/map/declare/map'; +import { IMap, IMarker, IMarkerCluster, IPlaceSearch } from '@src/modules/map/declare/map'; import { Console } from 'console'; import { TreeService } from 'src/app/http-interceptors/tree.service'; import Viewer from 'viewerjs' @@ -67,7 +67,7 @@ export class FireForceComponent implements OnInit { } } //循环渲染出所有力量markers - cluster:any //力量聚合实例 + cluster:IMarkerCluster //力量聚合实例 createMarker(list){ let markerArrcluster = [] this.cluster ? this.cluster.setData([]) : null @@ -191,7 +191,7 @@ export class FireForceComponent implements OnInit { } }) } - }) + },this) } diff --git a/src/app/data-collection/linkage-forces/linkage-forces.component.ts b/src/app/data-collection/linkage-forces/linkage-forces.component.ts index b8d75cb..de37e6c 100644 --- a/src/app/data-collection/linkage-forces/linkage-forces.component.ts +++ b/src/app/data-collection/linkage-forces/linkage-forces.component.ts @@ -176,7 +176,7 @@ export class LinkageForcesComponent implements OnInit { item.location?this.positionLngLat = item.location:null this.AttachmentArr = JSON.parse(item.relevantInfomationData) } - }) + },this) } diff --git a/src/app/data-collection/water-collection/water-collection.component.ts b/src/app/data-collection/water-collection/water-collection.component.ts index ef65695..9c0e730 100644 --- a/src/app/data-collection/water-collection/water-collection.component.ts +++ b/src/app/data-collection/water-collection/water-collection.component.ts @@ -135,7 +135,7 @@ export class WaterCollectionComponent implements OnInit { item.waterSourceType == 2 && item.detailData ? this.naturalWaterData = JSON.parse(item.detailData) : null this.positionLngLat = item.location } - }) + },this) } diff --git a/src/app/gis-management/gis-labeling/gis-labeling.component.ts b/src/app/gis-management/gis-labeling/gis-labeling.component.ts index 5a07972..c4e81a8 100644 --- a/src/app/gis-management/gis-labeling/gis-labeling.component.ts +++ b/src/app/gis-management/gis-labeling/gis-labeling.component.ts @@ -458,7 +458,7 @@ export class GisLabelingComponent implements OnInit { this.renderer2.listen(this.elementRef.nativeElement.querySelector('#seePlan'), 'click', (event) => { this.seePlan(item) })//查看预案点击事件 this.renderer2.listen(this.elementRef.nativeElement.querySelector('#share'), 'click', (event) => { this.share(item) })//分享点击事件 } - }) + },this) } @@ -915,7 +915,7 @@ export class GisLabelingComponent implements OnInit { if (e.clusterData.length == 1) { } - }) + },this) } //取消显示水源 diff --git a/src/app/key-unit/water-road/water-road.component.ts b/src/app/key-unit/water-road/water-road.component.ts index 2118980..be76b67 100644 --- a/src/app/key-unit/water-road/water-road.component.ts +++ b/src/app/key-unit/water-road/water-road.component.ts @@ -266,7 +266,7 @@ export class WaterRoadComponent implements OnInit { if(e.clusterData.length == 1){ } - }) + },this) } diff --git a/src/modules/map/declare/keda-map.ts b/src/modules/map/declare/keda-map.ts index f5c4a59..d39e335 100644 --- a/src/modules/map/declare/keda-map.ts +++ b/src/modules/map/declare/keda-map.ts @@ -1,4 +1,4 @@ -import { AutocompleteSearchCallback, AutocompleteSelectCallback, ClickOptions, DrivingSearchCallback, EventCallback, HtmlRender, IAutocomplete, ICircle, IDriving, IInfoWindow, ILayer, ILngLat, IMap, IMapOptions, IMarker, IMarkerCluster, IMarkOptions, IMouseTool, IPixel, IPlaceSearch, IRenderClusterMarker, ISelf, ITileLayer, PixelRender, PlaceSearchCallback } from './map' +import { AutocompleteSearchCallback, AutocompleteSelectCallback, ClickOptions, DrivingSearchCallback, EventCallback, HtmlRender, IAutocomplete, ICircle, IDriving, IInfoWindow, ILayer, ILngLat, IMap, IMapOptions, IMarker, IMarkerCluster, IMarkOptions, IMouseTool, IPixel, IPlaceSearch, IRenderClusterMarker, ISelf, ITileLayer, MarkerClusterCallback, PixelRender, PlaceSearchCallback } from './map' import { SearchDownList } from './component/SearchDownListPlugins/SearchDownList'; import { SearchService } from '@src/app/searchComponent.service'; import * as ObjectID from 'bson-objectid'; @@ -495,14 +495,39 @@ export class KedaCircle extends KedaBasic implements ICircle { //圆形 图层 } export class KedaMarkerCluster extends KedaBasic implements IMarkerCluster { //Marker 聚合物 + public map:KeDaMap + public id:string constructor(map: IMap, list: Object[], options: any) { super(); - } - on(eventName: string, callback: Function): void { - throw new Error('Method not implemented.'); + this.map = map + } + on(eventName: string, callback: MarkerClusterCallback, component?: any): void { + // 绑定聚合事件时获取信息 + this.map.self.addEventOnLayerObject({ + layerId: this.id, + event: eventName, + handler: (e, info) => { + //查询聚合详情 + if (info.type === 'aggs') { + this.map.self.queryClusterDetail({ + queryOptions: info, + serviceName: 'service_tzn_test7', + maxCount: 999, + callback: function (res) { + console.log(res, '聚合详情'); + callback.call(component,res) + } + }); + } else if (info.type === 'details') { + console.log(info.data,'聚合详情'); + } + } + }); } setData(list: any[]) { - throw new Error('Method not implemented.'); + if (!list.length) { + this.map.self.removeLayer({layerId: this.id}); + } } } diff --git a/src/modules/map/declare/map.d.ts b/src/modules/map/declare/map.d.ts index 9e8899a..6f0a9a1 100644 --- a/src/modules/map/declare/map.d.ts +++ b/src/modules/map/declare/map.d.ts @@ -43,8 +43,17 @@ export interface IMarker extends ISelf { setMap(); } +export class MarkerClusterOptions { //聚合物 click 数据类型 + cluster:any[] + clusterData:any[] + lnglat:ILngLat + target:any + markers:IMarker[] +} + +type MarkerClusterCallback = (event:MarkerClusterOptions)=>void; export interface IMarkerCluster extends ISelf { - on(eventName: string, callback: Function): void; + on(eventName: string, callback: MarkerClusterCallback, component?: any): void; setData(list: any[]); }