resident.js
2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import EventBus from '../event-bus'
import mapService from './mapService.js'
import MAPGEO from './mapgeo'
//常驻地
const resident = {
data: [],
markers: {},
infowins: {},
bindEvent(){
EventBus.$on('uiMap.resident.draw', (data)=>{
this.destroy();
this.draw(data);
});
EventBus.$on('uiMap.resident.destroy', ()=>{
this.destroy()
});
EventBus.$on('uiMap.resident.openInfoWindow', (idx)=>{
if(this.markers[idx]){
const MAP = mapService.map;
const lnglat = this.markers[idx].getPosition();
this.infowins[idx].open(MAP, lnglat);
MAP.setZoomAndCenter(MAP.getZoom(), lnglat);
}
});
},
draw(data){
const MAP = mapService.map;
this.data = data;
// MAPGEO.transferAddressByGroup(this, ()=>{
// EventBus.$emit('uiMap.historyLocation.transferSuccess', data);
// this.data.forEach((item)=>{
// if(parseFloat(item.elng) === 0 && parseFloat(item.elat) === 0) return;
// let marker = mapService.createConstantMarker([parseFloat(item.elng), parseFloat(item.elat)], MAP);
// let infoWindow = mapService.bindResidentInfoWindow(marker, MAP, item);
// this.markers[item.idx] = marker;
// this.infowins[item.idx] = infoWindow;
// });
// mapService.setFitView(MAP);
// });
// v1.7.0常驻地为保证导出内容与显示一致 取后端返回的address 不需高德逆地址解析
EventBus.$emit('uiMap.historyLocation.transferSuccess', data);
this.data.forEach((item)=>{
if(parseFloat(item.elng) === 0 && parseFloat(item.elat) === 0) return;
let marker = mapService.createConstantMarker([parseFloat(item.elng), parseFloat(item.elat)], MAP);
let infoWindow = mapService.bindResidentInfoWindow(marker, MAP, item);
this.markers[item.idx] = marker;
this.infowins[item.idx] = infoWindow;
});
mapService.setFitView(MAP);
},
intervalDraw(){
},
destroy: function(){
const MAP = mapService.map;
for(let idx in this.markers){
MAP.remove(this.markers[idx])
}
for(let idx in this.infowins){
MAP.remove(this.infowins[idx])
}
this.markers = {};
this.infowins = {};
this.clearTimeoutIds();
},
clearTimeoutIds(){
this.timeoutIds && this.timeoutIds.forEach((item)=>{
item && window.clearTimeout(item);
});
this.timeoutIds = []
}
}
export default resident;