| | |
| | | Number(pointList.value[1].latitude), |
| | | Number(pointList.value[1].height) |
| | | ) |
| | | |
| | | console.log(position1, position2) |
| | | |
| | | const carto1 = Cesium.Cartographic.fromCartesian(position1); |
| | | const carto2 = Cesium.Cartographic.fromCartesian(position2); |
| | | |
| | | const lon1 = Cesium.Math.toDegrees(carto1.longitude); |
| | | const lat1 = Cesium.Math.toDegrees(carto1.latitude); |
| | | const lon2 = Cesium.Math.toDegrees(carto2.longitude); |
| | | const lat2 = Cesium.Math.toDegrees(carto2.latitude); |
| | | |
| | | const west = Math.min(lon1, lon2); |
| | | const east = Math.max(lon1, lon2); |
| | | const south = Math.min(lat1, lat2); |
| | | const north = Math.max(lat1, lat2); |
| | | |
| | | viewer.entities.add({ |
| | | rectangle: { |
| | | coordinates: Cesium.Rectangle.fromDegrees(west, south, east, north), |
| | | material: Cesium.Color.RED.withAlpha(0.5), |
| | | outline: true, |
| | | outlineColor: Cesium.Color.RED, |
| | | outlineWidth: 2, |
| | | height: 60, |
| | | extrudedHeight: 60, |
| | | heightReference: Cesium.HeightReference.NONE |
| | | } |
| | | }); |
| | | // 获取两点在屏幕上的位置 |
| | | // const screenPos1 = Cesium.SceneTransforms?.wgs84ToWindowCoordinates?.(viewer.scene, position1) |
| | | // || viewer.scene.cartesianToCanvasCoordinates(position1); |
| | |
| | | // rotation: angle // 弧度制旋转 |
| | | // } |
| | | // }); |
| | | viewer.entities.add({ |
| | | id: `line`, |
| | | polyline: { |
| | | width: 2, |
| | | eyeOffset: new Cesium.Cartesian3(0, 0, -6), |
| | | material: arrowLineMaterialProperty, |
| | | clampToGround: false, |
| | | positions: [position1, position2], |
| | | }, |
| | | }) |
| | | // viewer.entities.add({ |
| | | // id: `line`, |
| | | // polyline: { |
| | | // width: 2, |
| | | // eyeOffset: new Cesium.Cartesian3(0, 0, -6), |
| | | // material: arrowLineMaterialProperty, |
| | | // clampToGround: false, |
| | | // positions: [position1, position2], |
| | | // }, |
| | | // }) |
| | | } |
| | | |
| | | // 禁用浏览器默认行为处理 |