欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

绘制多边形并进行拉伸

程序员文章站 2024-03-16 19:50:46
...

1,平面坐标点串

        var polygon = viewer.entities.add({
            polygon: {
                hierarchy: {
                    positions: [new Cesium.Cartesian3(6378136.282064899, 2045.931221366772, -1942.1627961569236),
                        new Cesium.Cartesian3(6378136.401006819, 2059.9615452982202, -2009.4381889716935),
                        new Cesium.Cartesian3(6378136.323519128, 2120.403271677589, -2010.7963412229758),
                        new Cesium.Cartesian3(6378136.231778225, 2123.366119812282, -1930.1244599529364)
                    ]
                },
                perPositionHeight: true,//对每个位置使用options.positions的height,而不使用options.height来确定高度
                extrudedHeight: 100,
                material: Cesium.Color.BLUE.withAlpha(0.5),
                outline: true,
                outlineColor: Cesium.Color.BLACK.withAlpha(1)//黑色轮廓线
            }
        });
        viewer.zoomTo(polygon);

2,经纬度坐标点串

                            var pointArray = new Array();
                            for (var j = 0; j < data.geometry.points.length; j++) {
                                var x = data.geometry.points[j].x;
                                var y = data.geometry.points[j].y;
                                pointArray.push(x);
                                pointArray.push(y);
                                pointArray.push(JMGC + GD);
                            }

                            viewer.entities.add({
                                name:"房间号:" + FJH,
                                fjhInfo:FJH,
                                colorInfo:colorStr,
                                id: FW_HS_INDEX,
                                text:BDCDYH,
                                polygon: {
                                    hierarchy: Cesium.Cartesian3.fromDegreesArrayHeights(pointArray),
                                    extrudedHeight: JMGC,//多边形的挤出面和椭圆面之间的距离(以米为单位)。
                                    perPositionHeight: true,//对每个位置使用options.positions的height,而不使用options.height来确定高度
                                    // material : Cesium.Color.RED.withAlpha(0.5),//颜色及透明度设置
                                    material: Cesium.Color.fromAlpha(Cesium.Color.fromCssColorString(colorStr), .5),
                                    outline: true,
                                    outlineColor: Cesium.Color.BLACK.withAlpha(1)//黑色轮廓线
                                }
                            });

 

相关标签: 多边形拉伸