|
@ -45,6 +45,7 @@ export class MarkerCluster { |
|
|
infoWindow; |
|
|
infoWindow; |
|
|
mapContainer; |
|
|
mapContainer; |
|
|
data = []; //标注集合
|
|
|
data = []; //标注集合
|
|
|
|
|
|
dataInfo = {}; |
|
|
vroot; |
|
|
vroot; |
|
|
constructor() {} |
|
|
constructor() {} |
|
|
|
|
|
|
|
@ -54,7 +55,7 @@ export class MarkerCluster { |
|
|
|
|
|
|
|
|
async addData(_id, _data, isDefault) { |
|
|
async addData(_id, _data, isDefault) { |
|
|
this.infoWindow?.close?.(); |
|
|
this.infoWindow?.close?.(); |
|
|
|
|
|
Vue.prototype.mapInsOpenLayers.push(_id) |
|
|
//data.forEach(e => {
|
|
|
//data.forEach(e => {
|
|
|
// const lnglat = getLnglat(e.extData);
|
|
|
// const lnglat = getLnglat(e.extData);
|
|
|
// e.extData.longitude = lnglat[0];//点坐标经度 【必传字段】
|
|
|
// e.extData.longitude = lnglat[0];//点坐标经度 【必传字段】
|
|
@ -114,6 +115,7 @@ export class MarkerCluster { |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
this.dataInfo[_id] = _data; |
|
|
this.data.push(..._data); |
|
|
this.data.push(..._data); |
|
|
if(aryPoints.length > 0){ |
|
|
if(aryPoints.length > 0){ |
|
|
map2d.addPointByArr( |
|
|
map2d.addPointByArr( |
|
@ -122,20 +124,25 @@ export class MarkerCluster { |
|
|
true // 当前新加图层是否启用聚合效果
|
|
|
true // 当前新加图层是否启用聚合效果
|
|
|
); |
|
|
); |
|
|
console.log(aryPoints,_id,'点位数组') |
|
|
console.log(aryPoints,_id,'点位数组') |
|
|
} else { |
|
|
|
|
|
Vue.prototype.mapIns.removeLayerByName(_id); |
|
|
|
|
|
} |
|
|
} |
|
|
// if(Vue.prototype.isMapStatck){
|
|
|
if(Vue.prototype.isMapStatck){ |
|
|
// setTimeout(() => {
|
|
|
setTimeout(() => { |
|
|
// Vue.prototype.mapIns.pileIsShow("jhlayers", true);
|
|
|
Vue.prototype.mapIns.pileIsShow(_id, true); |
|
|
// }, 500);
|
|
|
}, 500); |
|
|
// }
|
|
|
} |
|
|
} |
|
|
|
|
|
removeLayer(id){ |
|
|
|
|
|
Vue.prototype.mapIns.removeLayerByName(id); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
removeData(_id, _data) { |
|
|
removeData(_id, _data) { |
|
|
|
|
|
if (!_data) return; |
|
|
|
|
|
if (!Array.isArray(data)) data = [_data]; |
|
|
|
|
|
const _vpmIndex = Vue.prototype.mapInsOpenLayers.findIndex(_id); |
|
|
|
|
|
if(_vpmIndex !== -1){ |
|
|
|
|
|
Vue.prototype.mapInsOpenLayers.splice(_vpmIndex) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const _dataTemp = []; |
|
|
|
|
|
if(this.dataInfo[_id]){ |
|
|
|
|
|
_dataTemp = this.dataInfo[_id] |
|
|
|
|
|
} |
|
|
_data.forEach((item, index) => { |
|
|
_data.forEach((item, index) => { |
|
|
const findIndex = this.data.findIndex( |
|
|
const findIndex = this.data.findIndex( |
|
|
(removeData) => removeData === item |
|
|
(removeData) => removeData === item |
|
@ -162,13 +169,20 @@ export class MarkerCluster { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (findIndex > -1) this.data.splice(findIndex, 1); |
|
|
if (findIndex > -1) this.data.splice(findIndex, 1); |
|
|
|
|
|
|
|
|
|
|
|
const _findIndex = _dataTemp.findIndex( |
|
|
|
|
|
(removeData) => removeData === item |
|
|
|
|
|
); |
|
|
|
|
|
if (_findIndex > -1) { |
|
|
|
|
|
_dataTemp.splice(_findIndex, 1); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
console.log('remove',_id,_data) |
|
|
console.log('remove',_id,_data) |
|
|
Vue.prototype.mapIns.removeLayerByName(_id); |
|
|
Vue.prototype.mapIns.removeLayerByName(_id); |
|
|
if(_data && Array.isArray(_data) && _data.length > 0){ |
|
|
if(_dataTemp.length > 0){ |
|
|
const self = this; |
|
|
const self = this; |
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
self.refreshLayer(_id, _data); |
|
|
self.refreshLayer(_id, _dataTemp); |
|
|
}, 500); |
|
|
}, 500); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|