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.newPositionMarker.on('dragend', (e)=>{
this.positionLngLat = {x: e.lnglat.lng, y: e.lnglat.lat}
})
},this)
//点击确定
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'),'click',(event)=>{
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.newPositionMarker.on('dragend', (e)=>{
this.positionLngLat = {x: e.lnglat.lng, y: e.lnglat.lat}
})
},this)
//点击确定
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'),'click',(event)=>{
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.newPositionMarker.on('dragend', (e)=>{
this.positionLngLat = {x: e.lnglat.lng, y: e.lnglat.lat}
})
},this)
//点击确定
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'),'click',(event)=>{
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)
this.markerPosition2 = { x: lnglat.KL, y: lnglat.kT }
// console.log(`${lnglat.KL},${lnglat.kT}`);
})
},this)
this.newPositionMarker.on('dragging', (e) => {
//console.log('dragging',e)
let lnglat = this.map.containerToLngLat(e.pixel)
this.newPositionMarker.setPosition(lnglat);
})
},this)
//点击确定
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'), 'click', (event) => {
this.map.clearMap();
@ -320,12 +320,12 @@ export class BasicinfoComponent implements OnInit {
let lnglat = this.map.containerToLngLat(e.pixel)
this.markerPosition2 = { x: lnglat.KL, y: lnglat.kT }
// console.log(`${lnglat.KL},${lnglat.kT}`);
})
},this)
this.newPositionMarker.on('dragging', (e) => {
//console.log('dragging',e)
let lnglat = this.map.containerToLngLat(e.pixel)
this.newPositionMarker.setPosition(lnglat);
})
},this)
//点击确定
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'), 'click', (event) => {
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.showInfoClick(e)
});
},this);
this.map.on("complete", () => {
for (const key in this.canvasData.originaleveryStoreyData.data) {
if (Object.prototype.hasOwnProperty.call(this.canvasData.originaleveryStoreyData.data, key)) {
@ -1465,13 +1465,13 @@ export class CollectionToolsPlanComponent implements OnInit {
console.log(e)
this.clickId = e.target.id
this.setAssetsProperty(this.canvasData.originaleveryStoreyData.data[e.target.id])
});
},this);
startMarker.on('dragend', (e) => {
// console.log('拖拽完成', e)
this.canvasData.isChange = true
this.clickId = e.target.id
this.canvasData.originaleveryStoreyData.data[e.target.id].Point = { x: e.lnglat.lng, y: e.lnglat.lat }
});
},this);
this.planDataMarkers.push(startMarker)
this.map.add(startMarker);
}
@ -2252,13 +2252,13 @@ export class CollectionToolsPlanComponent implements OnInit {
startMarker.on('click', (e) => {
this.clickId = e.target.id
this.setAssetsProperty(this.canvasData.originaleveryStoreyData.data[e.target.id])
});
},this);
startMarker.on('dragend', (e) => {
// console.log('拖拽完成', e)
this.canvasData.isChange = true
this.clickId = e.target.id
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))

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 { SearchService } from '@src/app/searchComponent.service';
import * as ObjectID from 'bson-objectid';
@ -154,17 +154,27 @@ export class KeDaMap extends KedaBasic implements IMap {
});
return center
}
on(eventName: string, callback: Function): void {
on(eventName: string, callback: EventCallback, component?: any) {
let eventMapProfile = {
complete: "load",
click: "click",
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({
event: eventMapProfile[eventName],
handler: callback
});
}
}
}
export class KeDaPixel extends KedaBasic implements IPixel {
@ -237,10 +247,11 @@ export class KeDaMarker extends KedaBasic implements IMarker {
this.self.id = str
}
public bindObj = []; // event
on(eventName: string, callback: Function): void {
on(eventName: string, callback: EventCallback, component?: any) {
this.bindObj.push({
eventName: eventName,
callback: callback,
component: component,
});
this.startBindEvent();
}
@ -250,7 +261,12 @@ export class KeDaMarker extends KedaBasic implements IMarker {
this.map.self.addEventOnMarkers({
selector: `.${this.id}`,
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 = [];

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

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

Loading…
Cancel
Save