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

231 lines
6.2 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 ByjcLayer extends BaseLayer {
static LayerName = 'ByjcLayer';
static SourceName = SourceName;
getStyle() {
const ret = clone(ShapeStyle);
this._setStyleVisibility(ret);
return ret;
}
getName() {
return ByjcLayer.LayerName;
}
getSubLayers() {
return [ShapeStyle.id];
}
async doRefreshLayer(mapCtrl) {
const ms = mapCtrl.getSource(SourceName);
let data =
// await PicStPromise.get();
[
{
"res_cd": "42118140004",
"res_nm": "永丰水库",
"province_cd": "420000000000",
"province_nm": "湖北省",
stnm:'0FA5DE',
"city_cd": "421100000000",
"city_nm": "黄冈市",
"county_cd": "421181000000",
"county_nm": "麻城市",
"town_cd": "421181003000",
"town_nm": "南湖办事处",
"rv_name": "举水",
"bas_guid": "鄂东五河片区",
"res_lon": 115.05541,
"res_lat": 31.11106,
"res_reg_cd": "42118140042-A4",
"eng_scal": "小1型",
"eng_g": "IV",
"children": [
{
"res_cd": "42118140004",
"res_nm": "永丰水库",
"cd": 5821,
"cd_nm": "永丰水库",
"termite_status": "n",
"tm": "2025-05-21 09:18:28",
"is_main_cd": "y"
}
]
},
{
"res_cd": "42118140015",
"res_nm": "麻城坳水库",
"province_cd": "420000000000",
"province_nm": "湖北省",
"city_cd": "421100000000",
"city_nm": "黄冈市",
"county_cd": "421181000000",
"county_nm": "麻城市",
"town_cd": "421181107000",
"town_nm": "盐田河镇",
"rv_name": "举水",
"bas_guid": "鄂东五河片区",
"res_lon": 115.22541,
"res_lat": 30.98156,
"res_reg_cd": "42118140025-A4",
"eng_scal": "小1型",
"eng_g": "IV",
"children": [
{
"res_cd": "42118140015",
"res_nm": "麻城坳水库",
"cd": 5820,
"cd_nm": "麻城坳水库",
"termite_status": "y",
"tm": "2025-05-21 04:27:18",
"is_main_cd": "y"
}
]
},
{
"res_cd": "42118140023",
"res_nm": "游家冲水库",
"province_cd": "420000000000",
"province_nm": "湖北省",
"city_cd": "421100000000",
"city_nm": "黄冈市",
"county_cd": "421181000000",
"county_nm": "麻城市",
"town_cd": "421181109000",
"town_nm": "木子店镇",
"rv_name": "巴河",
"bas_guid": "鄂东五河片区",
"res_lon": 115.29541,
"res_lat": 31.20317,
"res_reg_cd": "42118140044-A4",
"eng_scal": "小1型",
"eng_g": "IV",
"children": [
{
"res_cd": "42118140023",
"res_nm": "游家冲水库",
"cd": 5819,
"cd_nm": "游家冲水库",
"termite_status": "n",
"tm": "2025-05-21 04:25:56",
"is_main_cd": "y"
}
]
},
{
"res_cd": "42118140013",
"res_nm": "高峰水库",
stnm:'0A82AD',
"province_cd": "420000000000",
"province_nm": "湖北省",
"city_cd": "421100000000",
"city_nm": "黄冈市",
"county_cd": "421181000000",
"county_nm": "麻城市",
"town_cd": "421181106000",
"town_nm": "龟山镇",
"rv_name": "举水",
"bas_guid": "鄂东五河片区",
"res_lon": 115.21201,
"res_lat": 31.05011,
"res_reg_cd": "42118140010-A4",
"eng_scal": "小1型",
"eng_g": "IV",
"children": null
},
{
"res_cd": "42118140039",
"res_nm": "姚家河水库",
"province_cd": "420000000000",
"province_nm": "湖北省",
"city_cd": "421100000000",
"city_nm": "黄冈市",
"county_cd": "421181000000",
"county_nm": "麻城市",
"town_cd": "421181113000",
"town_nm": "乘马岗镇",
"rv_name": "举水",
"bas_guid": "鄂东五河片区",
"res_lon": 114.9355,
"res_lat": 31.28804,
"res_reg_cd": "42118140041-A4",
"eng_scal": "小1型",
"eng_g": "IV",
"children": null
}
].map((item)=>{
const obj = {...item}
obj.lgtd = item.res_lon - 0.0019
obj.lttd = item.res_lat - 0.0001
return obj
})
ms.setData(parseGeoJSON(data));
return true;
}
getFeatureTip(record) {
return record.stnm;
}
featureClicked(properties, dispatch) {
dispatch?.runtime.setInfoDlg({ layerId: 'ByjcLayer', properties: properties })
// dispatch.runtime.setFeaturePop({
// type: InfoPopNames.PicStPop,
// properties,
// coordinates: [properties.lgtd, properties.lttd],
// offsetPop: true,
// });
}
}