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

63 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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;
}
}