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": "716115301", "type": "sk", "hasRz": true, "stnm": "葡萄冲水库", "adcd": "421181110000", "wscd": null, "importancy": 0, "lgtd": 115.051389, "lttd": 31.423333, "elev": 0, "damel": 15.8, "dsflz": 14.73, "fsltdz": 14.3, "ddz": 9.48, "zcxsw": 14.3, "drpTm": "2025-04-11T05:00:00.000Z", "today": 0, "h1": 0, "h3": 0, "h6": 0, "h12": 0, "h24": 0, "h48": 0, "drpState": 2, "rz": 213.75, "w": 0.04, "a_fsltdz": 199.45, "rzTm": "2025-04-11T05:00:00.000Z", "rzWarning": 1, "rzState": 2, "pic": [ { "stcd": "716115301", "tm": "2023-03-12T08:02:00.000Z", "url": "http://223.75.53.106:8891/skjgimages/2023/0312/716115301/20230312160200.jpg" }, { "stcd": "716115301", "tm": "2023-03-12T07:11:00.000Z", "url": "http://223.75.53.106:8891/skjgimages/2023/0312/716115302/20230312151100.jpg" } ], "aRz": 199.45 }, { "stcd": "716115701", "type": "sk", "hasRz": true, "stnm": "二五冲水库", "adcd": "421181110000", "wscd": null, "importancy": 0, "lgtd": 115.087222, "lttd": 31.378333, "elev": 0, "damel": 11.2, "dsflz": 10.07, "fsltdz": 108.55, "ddz": 1.5, "zcxsw": 108.55, "drpTm": "2025-03-22T08:00:00.000Z", "today": 0, "h1": 0, "h3": 0, "h6": 0, "h12": 0, "h24": 0, "h48": 0, "drpState": 2, "rz": 99.65, "w": 0.038, "a_fsltdz": -8.899999999999991, "rzTm": "2025-03-22T08:00:00.000Z", "rzWarning": 0, "rzState": 2, "pic": [ { "stcd": "716115701", "tm": "2025-03-06T23:01:00.000Z", "url": "http://223.75.53.106:8891/skjgimages/2025/0307/716115701/20250307070100.jpg" }, { "stcd": "716115701", "tm": "2024-10-18T06:28:00.000Z", "url": "http://223.75.53.106:8891/skjgimages/2024/1018/716115702/20241018142800.jpg" } ], "aRz": -8.9 }, { "stcd": "61614200", "type": "sk", "hasRz": true, "stnm": "浮桥河水库", "adcd": "421181100000", "wscd": null, "importancy": 0, "lgtd": 114.875, "lttd": 31.166667, "elev": 0, "damel": 71.33, "dsflz": 68.04, "fsltdz": 64.89, "ddz": 51.78, "zcxsw": 64.89, "drpTm": "2025-06-03T02:00:00.000Z", "today": 0, "h1": 0, "h3": 0, "h6": 0, "h12": 0, "h24": 0, "h48": 16.5, "drpState": 1, "rz": 60.71, "w": 162.8, "a_fsltdz": -4.18, "rzTm": "2025-06-03T02:00:00.000Z", "rzWarning": 0, "rzState": 1, "aRz": -4.18 }] export default class ShuiyuandiLayer extends BaseLayer { static LayerName = 'ShuiyuandiLayer'; static SourceName = SourceName; getStyle() { const ret = clone(ShapeStyle); this._setStyleVisibility(ret); return ret; } getName() { return ShuiyuandiLayer.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 obj.lttd = item.lttd return obj }) ms.setData(parseGeoJSON(data)); return true; } getFeatureTip(record) { return ''; } featureClicked(properties, dispatch) { // dispatch.runtime.setFeaturePop({ // type: InfoPopNames.PicStPop, // properties, // coordinates: [properties.lgtd, properties.lttd], // offsetPop: true, // }); dispatch.runtime.setInfoDlg({ layerId: 'ShuiyuandiLayer',properties }) } }