| | |
| | | } |
| | | |
| | | /** |
| | | * 解析围栏点字符串 "经度*纬度,经度*纬度" → [[lon, lat], ...] |
| | | * 解析围栏点字符串 "经度_纬度,经度_纬度" → [[lon, lat], ...] |
| | | */ |
| | | private parseFencePoints(fencePoints: string): number[][] { |
| | | if (!fencePoints) return [] |
| | | if (!fencePoints) |
| | | return [] |
| | | return fencePoints.split(',').map((pair) => { |
| | | const [lon, lat] = pair.split('*').map(Number) |
| | | const [lon, lat] = pair.split('_').map(Number) |
| | | return [lon, lat] |
| | | }).filter(([lon, lat]) => !isNaN(lon) && !isNaN(lat)) |
| | | } |
| | |
| | | return |
| | | |
| | | fences.forEach((fence) => { |
| | | if (!fence.areas) return |
| | | if (!fence.areas) |
| | | return |
| | | |
| | | fence.areas.forEach((area) => { |
| | | if (area.areaStatus !== 1) return // 只渲染启用的区域 |
| | | if (area.areaStatus !== 1) |
| | | return // 只渲染启用的区域 |
| | | |
| | | const path = this.parseFencePoints(area.fencePoints) |
| | | if (path.length < 3) return |
| | | if (path.length < 3) |
| | | return |
| | | |
| | | const isRestricted = area.areaType === 2 |
| | | |
| | |
| | | zIndex: LAYER_Z_INDEX.FENCE, |
| | | }) |
| | | |
| | | polygon.on('mousemove', (e: any) => { |
| | | const label = area.areaName || (isRestricted ? '禁行区' : '运营区域 (ODD边界)') |
| | | polygon.on('click', (e: any) => { |
| | | const areaTypeLabel = isRestricted ? '禁行区域' : '可运营区域' |
| | | const areaId = area.id ?? '-' |
| | | const areaName = area.areaName || '-' |
| | | const content = ` |
| | | <div style="padding:10px 14px;font-size:13px;line-height:1.8;min-width:160px;"> |
| | | <div style="font-weight:600;font-size:14px;margin-bottom:6px;border-bottom:1px solid #f0f0f0;padding-bottom:6px;">${areaTypeLabel}</div> |
| | | <div><span style="color:#64748b;">区域ID</span><span style="float:right;color:#1e293b;font-weight:500;">${areaId}</span></div> |
| | | <div><span style="color:#64748b;">名称</span><span style="float:right;color:#1e293b;font-weight:500;">${areaName}</span></div> |
| | | </div>` |
| | | const infoWindow = new AMap.InfoWindow({ |
| | | content: `<div style="padding:4px 8px;font-size:12px;">${fence.electronicName} - ${label}</div>`, |
| | | content, |
| | | offset: new AMap.Pixel(0, -10), |
| | | closeWhenClickMap: true, |
| | | }) |
| | | infoWindow.open(this.map, e.lnglat) |
| | | }) |
| | | |
| | | polygon.on('mouseout', () => { |
| | | this.map.clearInfoWindow() |
| | | }) |
| | | |
| | | polygon.setMap(this.visible ? this.map : null) |