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

63 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-09-20 15:02:50 +08:00
import { SkRealPromiseWX } from "../../../../models/_/real";
import BaseLayer from "../baselayer";
import ShuikuMarker from "./ShuikuMarker";
export default class ShuiKuLayer extends BaseLayer {
static LayerName = 'ShuiKuLayer';
constructor(props) {
super(props);
this.highlights = {};
}
getLayerName() {
return ShuiKuLayer.LayerName;
}
onAdd() {
SkRealPromiseWX.get().then((data) => {
// if (Array.isArray(data)) {
// data.forEach(o => {
// const strarz = o.rz - o.fsltdz;
// if (!isNaN(strarz)) {
// o.strarz = strarz.toFixed(2);
// }
// });
// }
const list = data.map((i)=>{
return {
id : i.stcd,
name: i.stnm,
...i
}
})
this._dispatch.runtime.setMarkers({
[this.getLayerName()]: list || []
});
});
}
setSetting(setting) {
const highlights = setting?.highlight?.ShuiKuLayer;
if (highlights !== this._setting?.highlight?.ShuiKuLayer) {
const setting = {};
if (highlights) {
for (const h of highlights) {
setting[h] = true
}
}
this._dispatch.map.setMarkerSetting({
[this.getLayerName()]: setting,
});
}
this._setting = setting;
}
getComponentCls() {
return ShuikuMarker;
}
}