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

56 lines
1.3 KiB
JavaScript

import BaseLayer from "../baselayer";
import XjHdswMarker from "./XjHdswMarker";
export default class XjHdswLayer extends BaseLayer {
static LayerName = 'XjHdswLayer';
constructor(props) {
super(props);
this.highlights = {};
}
getLayerName() {
return XjHdswLayer.LayerName;
}
async onAdd() {
const hdData = await fetch(`${process.env.PUBLIC_URL}/data/geojson/wufeng/swzjyyl.json`)//五峰水位站简易雨量.json
.then(resp => resp.json())
.then(data => data.filter(o => o.STTP.indexOf("Z")!== -1 && o.STTPSTR!=="简易水位站"))
.catch(() => []);
if(hdData.length>0){
hdData.map(item=>{
item.stcd = item.stnm;
item.type = '2022年新建水位站'
});
}
this._dispatch.runtime.setMarkers({
[this.getLayerName()]: hdData || []
});
}
setSetting(setting) {
const highlights = setting?.highlight?.XjHdswLayer;
if (highlights !== this._setting?.highlight?.XjHdswLayer) {
const setting = {};
if (highlights) {
for (const h of highlights) {
setting[h] = true
}
}
this._dispatch.map.setMarkerSetting({
[this.getLayerName()]: setting,
});
}
this._setting = setting;
}
getComponentCls() {
return XjHdswMarker;
}
}