maxiaoxiao 6 kuukautta sitten
vanhempi
commit
99535668a9
1 muutettua tiedostoa jossa 42 lisäystä ja 2 poistoa
  1. 42 2
      src/common/js/common.js

+ 42 - 2
src/common/js/common.js

@@ -58,6 +58,10 @@ const handlerDrawing = function (PolyType, tooltipNum) { //(传入操作的Dra
                 viewer.enableCursorStyle = false;
                 viewer._element.style.cursor = '';
                 document.body.classList.add("drawCur");
+                // if (PolyType == "Polygon" && DrawHandler.polygon) {
+                //     DrawHandler.polygon._polygon._material._color._value = Cesium.Color.fromCssColorString('rgba(255,165,0, 0.5)')
+                //     DrawHandler.polyline._polyline._material._color._value = Cesium.Color.fromCssColorString('rgba(81, 255, 0, 1)')
+                // }
             } else {
                 viewer.enableCursorStyle = true;
                 document.body.classList.remove('drawCur');
@@ -104,8 +108,44 @@ const handlerDrawing = function (PolyType, tooltipNum) { //(传入操作的Dra
             }
             if (PolyType == "Polygon") {
                 // DrawHandler.polygon._polygon._material._color._value.alpha = 0.5 //绘制面透明度
-                DrawHandler.polygon._polygon._material._color._value = Cesium.Color.WHITE.withAlpha(0.3)
-                DrawHandler.polyline._polyline._material._color._value = Cesium.Color.RED
+                // DrawHandler.polygon._polygon._material._color._value = Cesium.Color.WHITE.withAlpha(0.3)
+                // DrawHandler.polyline._polyline._material._color._value = Cesium.Color.RED
+                var nPositions = [];
+                var nRegions = [];
+                // that.regions = [];
+                for (var pt of result.object.positions) {
+                    var cartographic = Cesium.Cartographic.fromCartesian(pt);
+                    var longitude = Cesium.Math.toDegrees(cartographic.longitude);
+                    var latitude = Cesium.Math.toDegrees(cartographic.latitude);
+                    var height = cartographic.height;
+                    // that.regions.push({ x: longitude, y: latitude });
+                    nPositions.push(longitude);
+                    nPositions.push(latitude);
+                    nRegions.push({ x: longitude, y: latitude });
+                }
+
+                // that.regions.push(that.regions[0]);
+
+                viewer.entities.removeAll();
+                let polygonEntity = new Cesium.Entity({
+                    id: "polygon",
+                    // position: Cesium.Cartesian3.fromDegreesArray([
+                    //   centerX,
+                    //   centerY,
+                    // ]),
+                    // classificationType: ClassificationType.TERRAIN,
+                    polygon: {
+                        hierarchy: new Cesium.PolygonHierarchy(
+                            new Cesium.Cartesian3.fromDegreesArray(nPositions)
+                        ),
+                        // positions: new Cesium.Cartesian3.fromDegreesArray(positions),
+                        material: Cesium.Color.WHITE.withAlpha(0.3),
+                        outline: true,
+                        outlineColor: Cesium.Color.RED,
+                        outlineWidth: 4,
+                    },
+                });
+                viewer.entities.add(polygonEntity);
             }
             let positions = cartographic(result.object.positions)
             tooltip.setVisible(false);