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

211 lines
4.7 KiB
JavaScript

import clone from "clone";
import { PicStPromise, TestPicStPromise } from "../../../../models/_/real";
import { parseGeoJSON } from "../../../../utils/tools";
import { InfoPopNames } from "../../InfoPops";
import BaseLayer from "./baselayer";
const SourceName = '水厂';
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.4,
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'
}
};
const page1 = [
{
"stcd": "61612610",
"type": "sk",
"hasRz": true,
"stnm": "三河口水厂",
"adcd": "421181109000",
"wscd": null,
"importancy": 0,
"lgtd": 115.166667,
"lttd": 31.333333,
"elev": 0,
"damel": 156.8,
"dsflz": 154.99,
"fsltdz": 149,
"ddz": 124,
"zcxsw": 149,
"drpTm": "2025-06-03T02:00:00.000Z",
"today": 0,
"h1": 0,
"h3": 0,
"h6": 0,
"h12": 0,
"h24": 0,
"h48": 12.5,
"drpState": 1,
"rz": 141.45,
"w": 77.8,
"a_fsltdz": -7.550000000000011,
"rzTm": "2025-06-03T01:00:00.000Z",
"rzWarning": 0,
"rzState": 1,
"aRz": -7.55
},
{
"stcd": "7CS000231",
"type": "sk",
"hasRz": true,
"stnm": "刘集水厂",
"adcd": "421181100000",
"wscd": null,
"importancy": 0,
"lgtd": 115.048056,
"lttd": 31.335556,
"elev": 0,
"damel": 79.6,
"dsflz": 78.65,
"fsltdz": 72.05,
"ddz": 69.55,
"zcxsw": 72.05,
"drpTm": "2023-11-20T01:00:00.000Z",
"today": 0,
"h1": 0,
"h3": 0,
"h6": 0,
"h12": 0,
"h24": 0,
"h48": 0,
"drpState": 2,
"rz": 76.49,
"w": 0.049,
"a_fsltdz": 4.439999999999998,
"rzTm": "2025-04-11T06:00:00.000Z",
"rzWarning": 1,
"rzState": 2,
"pic": [
{
"stcd": "7CS000231",
"tm": "2023-11-20T01:04:18.000Z",
"url": "http://223.75.53.106:8891/skjgimages/2023/1120/7CS000231/20231120090418.jpg"
},
{
"stcd": "7CS000231",
"tm": "2023-11-20T01:07:54.000Z",
"url": "http://223.75.53.106:8891/skjgimages/2023/1120/7CS000232/20231120090754.jpg"
}
],
"aRz": 4.44
},
{
"stcd": "716460001",
"type": "sk",
"hasRz": true,
"stnm": "杉林河水厂",
"adcd": "421181107000",
"wscd": null,
"importancy": 0,
"lgtd": 115.433056,
"lttd": 31.304444,
"elev": 0,
"damel": 236.2,
"dsflz": 233.92,
"fsltdz": 231,
"ddz": 204,
"zcxsw": 231,
"drpTm": "2025-04-11T05:00:00.000Z",
"today": 0,
"h1": 0,
"h3": 0,
"h6": 0,
"h12": 0,
"h24": 0,
"h48": 0,
"drpState": 2,
"rz": 224.31,
"w": 0,
"a_fsltdz": -6.689999999999998,
"rzTm": "2025-04-11T05:00:00.000Z",
"rzWarning": 0,
"rzState": 2,
"aRz": -6.69
},
]
export default class ShuichangLayer extends BaseLayer {
static LayerName = 'ShuichangLayer';
static SourceName = SourceName;
getStyle() {
const ret = clone(ShapeStyle);
this._setStyleVisibility(ret);
return ret;
}
getName() {
return ShuichangLayer.LayerName;
}
getSubLayers() {
return [ShapeStyle.id];
}
async doRefreshLayer(mapCtrl) {
const ms = mapCtrl.getSource(SourceName);
let data =
// await PicStPromise.get();
[...page1].map((item)=>{
const obj = {...item}
obj.lgtd = item.lgtd - 0.00122
obj.lttd = item.lttd
return obj
})
ms.setData(parseGeoJSON(data));
return true;
}
getFeatureTip(record) {
return '';
}
featureClicked(properties, dispatch) {
// dispatch.runtime.setFeaturePop({
// type: 'shuichang',
// properties,
// coordinates: [properties.lgtd, properties.lttd],
// offsetPop: true,
// });
dispatch.runtime.setInfoDlg({ layerId: 'ShuichangLayer',properties })
}
}