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

128 lines
2.6 KiB
JavaScript
Raw Normal View History

2025-06-04 20:45:32 +08:00
import clone from "clone";
import { HDRealPromise } from "../../../../models/_/real";
import { parseGeoJSON } from "../../../../utils/tools";
import { InfoPopNames } from "../../InfoPops";
import BaseLayer from "./baselayer";
const SourceName = '实时河道水位Q2';
const Style = {
id: '实时河道水位Q2',
type: 'symbol',
source: SourceName,
layout: {
'icon-allow-overlap': true,
'text-allow-overlap': true,
'icon-image': '水位站-警戒',
'icon-size': [
'interpolate', ['linear'], ['zoom'],
10, 0.8,
14, 1,
],
'text-size': [
'interpolate', ['linear'], ['zoom'],
10, 10,
14, 16,
],
'text-max-width': 30,
'text-font': ['Roboto Black'],
'text-field': [
'step',
['zoom'],
[
'case',
['!=', ['get', 'state'], 1], '',
['concat', ['get', 'rz'], 'm']
],
12, [
'case',
['!=', ['get', 'state'], 1], ['get', 'stnm'],
[
'format',
['get', 'stnm'], { 'font-scale': 0.8, 'text-color': '#fff' },
'\n', {},
['concat', ['get', 'rz'], 'm'], {}
]
],
],
'text-anchor': 'top',
'text-offset': [0, 1],
'visibility': 'none',
},
paint: {
'text-color': [
'case',
['!=', ['get', 'state'], 1], '#888',
['==', ['get', 'warning'], 3], '#f00',
['==', ['get', 'warning'], 2], 'yellow',
['==', ['get', 'warning'], 1], 'yellow',
'#0f0'
],
'text-halo-color': '#062040',
'text-halo-width': 1
}
};
export default class RealHDLayerQ2 extends BaseLayer {
static LayerName = 'RealHDLayerQ2';
static SourceName = SourceName;
getStyle() {
const ret = clone(Style);
this._setStyleVisibility(ret);
return ret;
}
getName() {
return RealHDLayerQ2.LayerName;
}
getSubLayers() {
return [Style.id];
}
getRefreshInterval() {
return 60 * 1000;
}
async doRefreshLayer(mapCtrl) {
const ms = mapCtrl.getSource(SourceName);
const data = [{
"stcd": "61612900",
"stnm": "阎家河",
"adcd": null,
"wscd": null,
"importancy": 0,
"lgtd": 115.128722,
"lttd": 31.207,
"elev": null,
"hasRz": true,
"type": "sw",
"tm": "2025-06-03T02:00:00.000Z",
"rz": 61.75,
"state": 1
}];
ms.setData(parseGeoJSON(data));
return true;
}
getFeatureTip(record) {
return record.stnm;
}
featureClicked(properties, dispatch) {
dispatch.runtime.setFeaturePop({
type: InfoPopNames.RealHDPop,
properties,
coordinates: [properties.lgtd, properties.lttd],
offsetPop: true,
});
}
}