Browse Source

事件监听对接科达

上海一张图
陈鹏飞 4 years ago
parent
commit
db0055fe62
  1. 2
      src/app/data-collection/fire-force/fire-force.component.ts
  2. 2
      src/app/data-collection/linkage-forces/linkage-forces.component.ts
  3. 2
      src/app/data-collection/water-collection/water-collection.component.ts
  4. 8
      src/app/key-unit/basicinfo/basicinfo.component.ts
  5. 10
      src/app/ui/collection-tools-plan/collection-tools.component.ts
  6. 24
      src/modules/map/declare/keda-map.ts
  7. 12
      src/modules/map/declare/map.d.ts

2
src/app/data-collection/fire-force/fire-force.component.ts

@ -860,7 +860,7 @@ export class FireForceComponent implements OnInit {
this.isMapLabel = true this.isMapLabel = true
this.newPositionMarker.on('dragend', (e)=>{ this.newPositionMarker.on('dragend', (e)=>{
this.positionLngLat = {x: e.lnglat.lng, y: e.lnglat.lat} this.positionLngLat = {x: e.lnglat.lng, y: e.lnglat.lat}
}) },this)
//点击确定 //点击确定
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'),'click',(event)=>{ this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'),'click',(event)=>{
this.isGisTopBox = false this.isGisTopBox = false

2
src/app/data-collection/linkage-forces/linkage-forces.component.ts

@ -581,7 +581,7 @@ export class LinkageForcesComponent implements OnInit {
this.isMapLabel = true this.isMapLabel = true
this.newPositionMarker.on('dragend', (e)=>{ this.newPositionMarker.on('dragend', (e)=>{
this.positionLngLat = {x: e.lnglat.lng, y: e.lnglat.lat} this.positionLngLat = {x: e.lnglat.lng, y: e.lnglat.lat}
}) },this)
//点击确定 //点击确定
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'),'click',(event)=>{ this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'),'click',(event)=>{
this.isGisTopBox = false this.isGisTopBox = false

2
src/app/data-collection/water-collection/water-collection.component.ts

@ -588,7 +588,7 @@ export class WaterCollectionComponent implements OnInit {
this.isMapLabel = true this.isMapLabel = true
this.newPositionMarker.on('dragend', (e)=>{ this.newPositionMarker.on('dragend', (e)=>{
this.positionLngLat = {x: e.lnglat.lng, y: e.lnglat.lat} this.positionLngLat = {x: e.lnglat.lng, y: e.lnglat.lat}
}) },this)
//点击确定 //点击确定
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'),'click',(event)=>{ this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'),'click',(event)=>{
this.isGisTopBox = false this.isGisTopBox = false

8
src/app/key-unit/basicinfo/basicinfo.component.ts

@ -231,12 +231,12 @@ export class BasicinfoComponent implements OnInit {
let lnglat = this.map.containerToLngLat(e.pixel) let lnglat = this.map.containerToLngLat(e.pixel)
this.markerPosition2 = { x: lnglat.KL, y: lnglat.kT } this.markerPosition2 = { x: lnglat.KL, y: lnglat.kT }
// console.log(`${lnglat.KL},${lnglat.kT}`); // console.log(`${lnglat.KL},${lnglat.kT}`);
}) },this)
this.newPositionMarker.on('dragging', (e) => { this.newPositionMarker.on('dragging', (e) => {
//console.log('dragging',e) //console.log('dragging',e)
let lnglat = this.map.containerToLngLat(e.pixel) let lnglat = this.map.containerToLngLat(e.pixel)
this.newPositionMarker.setPosition(lnglat); this.newPositionMarker.setPosition(lnglat);
}) },this)
//点击确定 //点击确定
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'), 'click', (event) => { this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'), 'click', (event) => {
this.map.clearMap(); this.map.clearMap();
@ -320,12 +320,12 @@ export class BasicinfoComponent implements OnInit {
let lnglat = this.map.containerToLngLat(e.pixel) let lnglat = this.map.containerToLngLat(e.pixel)
this.markerPosition2 = { x: lnglat.KL, y: lnglat.kT } this.markerPosition2 = { x: lnglat.KL, y: lnglat.kT }
// console.log(`${lnglat.KL},${lnglat.kT}`); // console.log(`${lnglat.KL},${lnglat.kT}`);
}) },this)
this.newPositionMarker.on('dragging', (e) => { this.newPositionMarker.on('dragging', (e) => {
//console.log('dragging',e) //console.log('dragging',e)
let lnglat = this.map.containerToLngLat(e.pixel) let lnglat = this.map.containerToLngLat(e.pixel)
this.newPositionMarker.setPosition(lnglat); this.newPositionMarker.setPosition(lnglat);
}) },this)
//点击确定 //点击确定
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'), 'click', (event) => { this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'), 'click', (event) => {
this.isGisTopBox = true this.isGisTopBox = true

10
src/app/ui/collection-tools-plan/collection-tools.component.ts

@ -1429,7 +1429,7 @@ export class CollectionToolsPlanComponent implements OnInit {
this.map.on('click', (e) => { this.map.on('click', (e) => {
this.showInfoClick(e) this.showInfoClick(e)
}); },this);
this.map.on("complete", () => { this.map.on("complete", () => {
for (const key in this.canvasData.originaleveryStoreyData.data) { for (const key in this.canvasData.originaleveryStoreyData.data) {
if (Object.prototype.hasOwnProperty.call(this.canvasData.originaleveryStoreyData.data, key)) { if (Object.prototype.hasOwnProperty.call(this.canvasData.originaleveryStoreyData.data, key)) {
@ -1465,13 +1465,13 @@ export class CollectionToolsPlanComponent implements OnInit {
console.log(e) console.log(e)
this.clickId = e.target.id this.clickId = e.target.id
this.setAssetsProperty(this.canvasData.originaleveryStoreyData.data[e.target.id]) this.setAssetsProperty(this.canvasData.originaleveryStoreyData.data[e.target.id])
}); },this);
startMarker.on('dragend', (e) => { startMarker.on('dragend', (e) => {
// console.log('拖拽完成', e) // console.log('拖拽完成', e)
this.canvasData.isChange = true this.canvasData.isChange = true
this.clickId = e.target.id this.clickId = e.target.id
this.canvasData.originaleveryStoreyData.data[e.target.id].Point = { x: e.lnglat.lng, y: e.lnglat.lat } this.canvasData.originaleveryStoreyData.data[e.target.id].Point = { x: e.lnglat.lng, y: e.lnglat.lat }
}); },this);
this.planDataMarkers.push(startMarker) this.planDataMarkers.push(startMarker)
this.map.add(startMarker); this.map.add(startMarker);
} }
@ -2252,13 +2252,13 @@ export class CollectionToolsPlanComponent implements OnInit {
startMarker.on('click', (e) => { startMarker.on('click', (e) => {
this.clickId = e.target.id this.clickId = e.target.id
this.setAssetsProperty(this.canvasData.originaleveryStoreyData.data[e.target.id]) this.setAssetsProperty(this.canvasData.originaleveryStoreyData.data[e.target.id])
}); },this);
startMarker.on('dragend', (e) => { startMarker.on('dragend', (e) => {
// console.log('拖拽完成', e) // console.log('拖拽完成', e)
this.canvasData.isChange = true this.canvasData.isChange = true
this.clickId = e.target.id this.clickId = e.target.id
this.canvasData.originaleveryStoreyData.data[e.target.id].Point = { x: e.lnglat.lng, y: e.lnglat.lat } this.canvasData.originaleveryStoreyData.data[e.target.id].Point = { x: e.lnglat.lng, y: e.lnglat.lat }
}); },this);
//将图标数据添加 //将图标数据添加
let itemData = JSON.parse(JSON.stringify(this.selectImage)) let itemData = JSON.parse(JSON.stringify(this.selectImage))

24
src/modules/map/declare/keda-map.ts

@ -1,4 +1,4 @@
import { AutocompleteSearchCallback, AutocompleteSelectCallback, DrivingSearchCallback, 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, PixelRender, PlaceSearchCallback } from './map'
import { SearchDownList } from './component/SearchDownListPlugins/SearchDownList'; import { SearchDownList } from './component/SearchDownListPlugins/SearchDownList';
import { SearchService } from '@src/app/searchComponent.service'; import { SearchService } from '@src/app/searchComponent.service';
import * as ObjectID from 'bson-objectid'; import * as ObjectID from 'bson-objectid';
@ -154,18 +154,28 @@ export class KeDaMap extends KedaBasic implements IMap {
}); });
return center return center
} }
on(eventName: string, callback: Function): void { on(eventName: string, callback: EventCallback, component?: any) {
let eventMapProfile = { let eventMapProfile = {
complete: "load", complete: "load",
click: "click", click: "click",
rightclick: "contextmenu" rightclick: "contextmenu"
}; };
if (eventName == "click") {
this.self.addEventOnMap({event: "click",
handler: (res)=>{
console.log(res,'地图点击')
var d:ClickOptions = res.data.map();
callback.call(component,d);
}
});
} else {
this.self.addEventOnMap({ this.self.addEventOnMap({
event: eventMapProfile[eventName], event: eventMapProfile[eventName],
handler: callback handler: callback
}); });
} }
} }
}
export class KeDaPixel extends KedaBasic implements IPixel { export class KeDaPixel extends KedaBasic implements IPixel {
constructor(x: number, y: number) { constructor(x: number, y: number) {
@ -237,10 +247,11 @@ export class KeDaMarker extends KedaBasic implements IMarker {
this.self.id = str this.self.id = str
} }
public bindObj = []; // event public bindObj = []; // event
on(eventName: string, callback: Function): void { on(eventName: string, callback: EventCallback, component?: any) {
this.bindObj.push({ this.bindObj.push({
eventName: eventName, eventName: eventName,
callback: callback, callback: callback,
component: component,
}); });
this.startBindEvent(); this.startBindEvent();
} }
@ -250,7 +261,12 @@ export class KeDaMarker extends KedaBasic implements IMarker {
this.map.self.addEventOnMarkers({ this.map.self.addEventOnMarkers({
selector: `.${this.id}`, selector: `.${this.id}`,
event: item.eventName, event: item.eventName,
handler: item.callback, handler: (res) =>{
console.log(res,'marker点击')
var d:ClickOptions = res.data.map();
d.target.id = this.self.id
item.callback.call(item.component,d)
}
}); });
}) })
this.bindObj = []; this.bindObj = [];

12
src/modules/map/declare/map.d.ts vendored

@ -3,8 +3,16 @@ export interface ISelf {
discriminator: string; discriminator: string;
} }
export class ClickOptions {
lnglat: ILngLat
pixel: IPixel
type: string
target: { id:string }
}
type EventCallback = (event?:ClickOptions)=>void;
export interface IMap extends ISelf { export interface IMap extends ISelf {
on(eventName: string, callback: Function); on(eventName: string, callback: EventCallback, component?: any);
add(obj: IMarker|ITileLayer|any); add(obj: IMarker|ITileLayer|any);
remove(obj: IMarker|ITileLayer|any); remove(obj: IMarker|ITileLayer|any);
clearMap(); clearMap();
@ -29,7 +37,7 @@ export interface IMapOptions {
export interface IMarker extends ISelf { export interface IMarker extends ISelf {
id: string; id: string;
_position:number[]; _position:number[];
on(eventName: string, callback: Function); on(eventName: string, callback: EventCallback, component?: any);
setPosition(x:ILngLat|number[]) setPosition(x:ILngLat|number[])
setContent(html:string) setContent(html:string)
setMap(); setMap();

Loading…
Cancel
Save