tsg-web/src/views/Home/MapCtrl/Markers/RealDrpAllLayer.js

63 lines
1.6 KiB
JavaScript
Raw Normal View History

2024-09-20 15:02:50 +08:00
import { DrpRealPromiseWX } from "../../../../models/_/real";
import BaseLayer from "../baselayer";
import RealDrpAllMarker from "./RealDrpAllMarker";
export default class RealDrpAllLayer extends BaseLayer {
static LayerName = 'RealDrpAllLayer';
constructor(props) {
super(props);
this.highlights = {};
this._visible = false;
this._layerSettings = {};
}
getLayerName() {
return RealDrpAllLayer.LayerName;
}
onAdd() {
// 此处为何会重复请求2次
DrpRealPromiseWX.get().then((data) => {
let list = []
console.log("RealDrpAllLayer.js", data);
// if (Array.isArray(data)) {
// if (this._layerSettings.skVisible) {
// list = data.filter(o => o.type !== 'SK' && o.type2 !== 'swsk');
// }
// if (this._layerSettings.hdVisible) {
// list = data.filter(o => !o.hasRz || o.type === 'SK' || o.type2 === 'swsk');
// }
// }
list = data.filter(o => o.lgtd && o.lttd && o.elem=='drp');//筛选一下,保证数据都是有经纬度的
this._dispatch.runtime.setMarkers({
[this.getLayerName()]: list || []
});
});
}
setSetting(setting) {
const highlights = setting?.highlight?.RealDrpAllLayer;
if (highlights !== this._setting?.highlight?.RealDrpAllLayer) {
const setting = {};
if (highlights) {
for (const h of highlights) {
setting[h] = true
}
}
this._dispatch.map.setMarkerSetting({
[this.getLayerName()]: setting,
});
}
this._setting = setting;
}
getComponentCls() {
return RealDrpAllMarker;
}
}