mcfxkh-Web/src/views/Home/MapCtrl/mapstyle/realsklayerQ2.js

150 lines
2.9 KiB
JavaScript

import clone from "clone";
import { SkRealPromise } from "../../../../models/_/real";
import { parseGeoJSON } from "../../../../utils/tools";
import { InfoPopNames } from "../../InfoPops";
import BaseLayer from "./baselayer";
const SourceName = '实时水库q2';
const ShapeStyle = {
id: SourceName,
type: 'symbol',
source: SourceName,
layout: {
'icon-allow-overlap': true,
'text-allow-overlap': true,
'icon-image': '水库-超汛限',
'icon-size': [
'interpolate', ['linear'], ['zoom'],
10, 0.8,
14, 0.8,
],
'text-allow-overlap': true,
'text-size': [
'interpolate', ['linear'], ['zoom'],
10, 10,
14, 14,
],
'text-font': ['Roboto Black'],
'text-field': [
'step',
['zoom'],
'',
12, ['get', 'stnm']
],
'text-anchor': 'top',
'text-offset': [0, 1],
'visibility': 'none',
},
paint: {
'text-color': '#fff'
}
};
export default class RealSkLayerQ2 extends BaseLayer {
static LayerName = 'RealSkLayerQ2';
static SourceName = SourceName;
getStyle() {
const ret = clone(ShapeStyle);
this._setStyleVisibility(ret);
return ret;
}
getName() {
return RealSkLayerQ2.LayerName;
}
getSubLayers() {
return [ShapeStyle.id];
}
getRefreshInterval() {
return 60 * 1000;
}
async doRefreshLayer(mapCtrl) {
const ms = mapCtrl.getSource(SourceName);
let data = [{
"stcd": "61614200",
"type": "sk",
"hasRz": true,
"stnm": "浮桥河水库",
"adcd": "421181100000",
"wscd": null,
"importancy": 0,
"lgtd": 114.88069,
"lttd": 31.171967,
"elev": 0,
"damel": 71.33,
"dsflz": 68.04,
"fsltdz": 64.89,
"ddz": 51.78,
"zcxsw": 64.89,
"jhhsw":68.7,
"drpTm": "2025-06-06T22:00:00.000Z",
"today": 4,
"h1": 4,
"h3": 4,
"h6": 4,
"h12": 4,
"h24": 4,
"h48": 4,
"drpState": 2,
"rz": 65.7,
"w": 45490,
"xs":32133,
"a_fsltdz": -4.189999999999998,
"rzTm": "2025-06-06T22:00:00.000Z",
"rzWarning": 1,
"rzState": 2,
"layer": "RealSkLayer",
"layerPop": "RealSkPop"
}];
if (Array.isArray(data)) {
data.forEach(o => {
const strarz = o.rz - o.fsltdz;
if (!isNaN(strarz)) {
o.strarz = strarz.toFixed(2);
}
});
}
ms.setData(parseGeoJSON(data));
return true;
}
getFeatureTip(record) {
return record.stnm;
}
featureClicked(properties, dispatch) {
if (properties.stnm === '小玉潭水库') {
/*
dispatch.runtime.setInfoDlg({
layerId: 'Three', properties: properties
});
*/
window.open('http://www.baidu.com')
} else {
dispatch.runtime.setFeaturePop({
type: InfoPopNames.RealSkPop,
properties,
coordinates: [properties.lgtd, properties.lttd],
offsetPop: true,
});
}
}
}