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

125 lines
2.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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'
}
};
export default class SljcLayer extends BaseLayer {
static LayerName = 'SljcLayer';
static SourceName = SourceName;
getStyle() {
const ret = clone(ShapeStyle);
this._setStyleVisibility(ret);
return ret;
}
getName() {
return SljcLayer.LayerName;
}
getSubLayers() {
return [ShapeStyle.id];
}
async doRefreshLayer(mapCtrl) {
const ms = mapCtrl.getSource(SourceName);
let data =
// await PicStPromise.get();
[{
"cd": "1",
"cd_nm": "WE",
"ch": "1",
"res_reg_cd": "42118140042-A4",
"res_cd": "42118140004",
"res_nm": "永丰水库",
"res_lon": 115.05541,
"res_lat": 31.11106,
"province_cd": "420000000000",
"province_nm": "湖北省",
"city_cd": "421100000000",
"city_nm": "黄冈市",
"county_cd": "421181000000",
"county_nm": "麻城市",
"town_cd": "421181003000",
"town_nm": "南湖办事处",
"danger_stat": "非病险水库",
"bas_guid": "鄂东五河片区",
"label": "2023高标准",
"eng_scal": "小1型",
"value": 0.3,
"diff_value": -0.02,
"trend": -1,
"dt": "2025-05-20",
"is_has_data": "y",
"max_value": 0.3
}].map((item)=>{
const obj = {...item}
obj.lgtd = item.res_lon
obj.lttd = item.res_lat
return obj
})
ms.setData(parseGeoJSON(data));
return true;
}
getFeatureTip(record) {
return record.stnm;
}
featureClicked(properties, dispatch) {
dispatch?.runtime.setInfoDlg({ layerId: 'SljcLayer', properties: properties })
// dispatch.runtime.setFeaturePop({
// type: InfoPopNames.PicStPop,
// properties,
// coordinates: [properties.lgtd, properties.lttd],
// offsetPop: true,
// });
}
}