| | |
| | | const store = useStore(); |
| | | const userInfo = computed(() => store.getters.userInfo); |
| | | const areaCode = userInfo.value?.detail?.areaCode || ''; |
| | | // console.log('用户信息',areaCode); |
| | | // 红色警告交叉面提示窗 |
| | | const isShowWaringTip = ref(false); |
| | | const activeName = ref('电子围栏'); |
| | |
| | | layerParams.value.folderOption = formattedFolderOption; |
| | | }); |
| | | }; |
| | | // 编辑围栏区域 |
| | | // const handleEdit = val => { |
| | | // console.log('编辑数据',val.geo_data); |
| | | |
| | | // viewer.entities.removeAll(); |
| | | // layerParams.value.editDetailData = val; |
| | | // drawPolygonExample.editThePatch(true); |
| | | // drawPolygonExample.drawTheArea(true); |
| | | // const positions = parseGeoDataToPositions(val.geo_data, val.altitude); |
| | | // if (positions.length < 3) return; // 少于3个点无法构成多边形 |
| | | // drawPolygonExample.initPolygon(viewer, positions, true); |
| | | // }; |
| | | // 编辑围栏区域 |
| | | const handleEdit = val => { |
| | | viewer.entities.removeAll(); |
| | | layerParams.value.editDetailData = val; |
| | | drawPolygonExample.editThePatch(true); |
| | | drawPolygonExample.drawTheArea(true); |
| | | // 移除最后一个点 |
| | | let geoDataArr = JSON.parse(val.geo_data); |
| | | if (geoDataArr.length > 0) { |
| | | geoDataArr.pop(); |
| | | } |
| | | const processedGeoData = JSON.stringify(geoDataArr); |
| | | // 使用处理后的 geo_data 解析坐标 |
| | | //geo_data 解析坐标 |
| | | const positions = parseGeoDataToPositions(processedGeoData, val.altitude); |
| | | if (positions.length < 3) return; // 少于3个点无法构成多边形 |
| | | drawPolygonExample.initPolygon(viewer, positions, true); |
| | |
| | | }; |
| | | // 点击显示区域 |
| | | const handleCoverDataUpdate = data => { |
| | | console.log('data',data); |
| | | |
| | | selectDataList.value = data; |
| | | if (selectDataList.value.length > 0) { |
| | | loadDataToMap(selectDataList.value); |
| | |
| | | tbJwdList = []; |
| | | dataList.forEach(item => { |
| | | let positions = parseGeoDataToPositions(item.geo_data, item.altitude); |
| | | // positions.push(positions[0]); |
| | | if (positions.length < 3) { |
| | | console.warn(`数据 ${item.name} 坐标点不足,无法绘制`); |
| | | return; |
| | | } |
| | | tbJwdList.push(...positions); |
| | | // 转换为 Cesium 所需的 [lng, lat, lng, lat, ...] 扁平数组格式 |
| | | let degreesArray = []; |
| | | positions.forEach(pos => { |
| | | degreesArray.push(pos.lng, pos.lat, pos.height); |
| | |
| | | focusOnAllFeatures(); |
| | | viewInstance.value?.addLeftClickEvent(null, handleFenceClick); |
| | | }; |
| | | //计算所有图斑的包围球并定位 |
| | | const focusOnAllFeatures = () => { |
| | | if (tbJwdList.length === 0 || !viewer) return; |
| | | |
| | | // 转换所有经纬度坐标为Cartesian3 |
| | | const allPositions = tbJwdList.flatMap(pos => |
| | | Cesium.Cartesian3.fromDegrees(pos.lng, pos.lat, pos.height || 0) |
| | | ); |
| | | if (allPositions.length === 0) return; |
| | | const boundingSphere = Cesium.BoundingSphere.fromPoints(allPositions); |
| | | viewer.camera.flyToBoundingSphere(boundingSphere, { |
| | | duration: 0, // 飞行时间(秒) |
| | | offset: new Cesium.HeadingPitchRange( |
| | | Cesium.Math.toRadians(0), // 方向角 |
| | | Cesium.Math.toRadians(-90) // 俯仰角 |
| | | ), |
| | | const positionsData = tbJwdList.map(pos => [ |
| | | pos.lng, |
| | | pos.lat, |
| | | pos.height || 0 |
| | | ]); |
| | | flyVisual({ |
| | | positionsData, |
| | | viewer, |
| | | multiple: 13, // 缩放倍数 |
| | | pitch: -90 |
| | | }); |
| | | }; |
| | | // 区域点击显示详细信息 |
| | |
| | | let viewer = null; |
| | | const viewInstance = shallowRef(null); |
| | | const homeViewer = shallowRef(null); |
| | | |
| | | // 初始化绘制工具实例 |
| | | const drawPolygonExample = new DrawPolygon(); |
| | | // 地图初始化 |
| | | const initMap = () => { |