"use client" import {useState} from "react" import {Circle, LayersControl, MapContainer, Marker, Polyline, Popup, TileLayer} from "react-leaflet" import {Badge, Card, Descriptions, Divider, Switch} from "antd" import {Icon} from "leaflet" import "leaflet/dist/leaflet.css" // 修复 Leaflet 默认图标问题 if (typeof window !== "undefined") { delete (Icon.Default.prototype as any)._getIconUrl Icon.Default.mergeOptions({ iconRetinaUrl: "https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-icon-2x.png", iconUrl: "https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-icon.png", shadowUrl: "https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-shadow.png", }) } const mockPipelineData = [ { id: "pipeline_001", name: "五一大道主干管", coordinates: [ [28.2282, 112.9388], [28.2292, 112.9398], [28.2302, 112.9408], [28.2312, 112.9418], ], pressure: "中压", material: "钢管", diameter: "DN400", status: "正常", }, { id: "pipeline_002", name: "芙蓉路支管", coordinates: [ [28.2312, 112.9418], [28.2322, 112.9428], [28.2332, 112.9438], ], pressure: "低压", material: "PE管", diameter: "DN200", status: "维护中", }, { id: "pipeline_003", name: "韶山路干管", coordinates: [ [28.2202, 112.9308], [28.2212, 112.9318], [28.2222, 112.9328], [28.2232, 112.9338], ], pressure: "高压", material: "钢管", diameter: "DN600", status: "正常", }, ] const mockMonitoringDevices = [ { id: "device_CS001", name: "压力监测点CS001", position: [28.2282, 112.9388], type: "压力监测", status: "在线", value: "0.28MPa", lastUpdate: "2024-01-15 14:30:00", }, { id: "device_CS002", name: "流量监测点CS002", position: [28.2302, 112.9408], type: "流量监测", status: "在线", value: "156m³/h", lastUpdate: "2024-01-15 14:29:45", }, { id: "device_CS003", name: "甲烷浓度监测CS003", position: [28.2322, 112.9428], type: "气体浓度", status: "报警", value: "0.6%LEL", lastUpdate: "2024-01-15 14:31:12", }, { id: "device_CS004", name: "温度监测点CS004", position: [28.2222, 112.9328], type: "温度监测", status: "在线", value: "15.2°C", lastUpdate: "2024-01-15 14:30:30", }, ] const mockHazardPoints = [ { id: "hazard_CS001", name: "管道老化隐患", position: [28.2292, 112.9398], level: "较大", type: "设备老化", description: "五一大道段管道使用年限超过20年,存在老化风险", status: "待处理", }, { id: "hazard_CS002", name: "地铁施工风险", position: [28.2332, 112.9438], level: "重大", type: "外部威胁", description: "芙蓉路地铁3号线施工,可能影响管道安全", status: "处理中", }, { id: "hazard_CS003", name: "道路改造影响", position: [28.2212, 112.9318], level: "一般", type: "外部威胁", description: "韶山路改造工程可能对管道造成影响", status: "已处理", }, ] const mockRiskAreas = [ { id: "risk_CS001", center: [28.2292, 112.9398], radius: 200, level: "较大风险", color: "#faad14", }, { id: "risk_CS002", center: [28.2332, 112.9438], radius: 300, level: "重大风险", color: "#f5222d", }, { id: "risk_CS003", center: [28.2212, 112.9318], radius: 150, level: "低风险", color: "#52c41a", }, ] // 自定义图标 const createCustomIcon = (color: string, symbol: string) => { return new Icon({ iconUrl: `data:image/svg+xml;base64,${btoa(` ${symbol} `)}`, iconSize: [25, 41], iconAnchor: [12, 41], popupAnchor: [1, -34], }) } const deviceIcon = createCustomIcon("#1890ff", "D") const hazardIcon = createCustomIcon("#faad14", "!") const criticalHazardIcon = createCustomIcon("#f5222d", "!!") interface GasNetworkMapProps { height?: string } export default function GasNetworkMap({ height = "600px" }: GasNetworkMapProps) { const [showPipelines, setShowPipelines] = useState(true) const [showDevices, setShowDevices] = useState(true) const [showHazards, setShowHazards] = useState(true) const [showRiskAreas, setShowRiskAreas] = useState(true) return (
管网管线
监测设备
隐患点位
风险区域
{/* 管网管线 */} {showPipelines && mockPipelineData.map((pipeline) => (

{pipeline.name}

{pipeline.id} {pipeline.pressure} {pipeline.material} {pipeline.diameter}
))} {/* 监测设备 */} {showDevices && mockMonitoringDevices.map((device) => (

{device.name}

{device.id} {device.type} {device.value} {device.lastUpdate}
))} {/* 隐患点位 */} {showHazards && mockHazardPoints.map((hazard) => (

{hazard.name}

{hazard.id} {hazard.type}

{hazard.description}

))} {/* 风险区域 */} {showRiskAreas && mockRiskAreas.map((area) => (

风险评估区域

风险等级:

影响半径: {area.radius}米

))}
) }