Cesium-1.62 Polygon.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <meta name="description" content="Draw a polygon or extruded polygon on the globe surface.">
    <meta name="cesium-sandcastle-labels" content="Geometries">
    <title>Cesium Polygon</title>
    <script type="text/javascript" src="../Sandcastle-header.js"></script>
    <script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/require.js"></script>
    <script type="text/javascript">
        if (typeof require === 'function') {
            require.config({
                baseUrl: '../../../Source',
                waitSeconds: 120
            });
        }
    </script>
</head>
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html">
<style>
    @import url(../templates/bucket.css);
</style>
<div id="cesiumContainer" class="fullSize"></div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar"></div>
<script id="cesium_sandcastle_script">
    function startup(Cesium) {
        'use strict';
        Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzNDhhYmQxOC1mYzMwLTRhYmEtOTI5Ny1iNGExNTQ3ZTZhODkiLCJpZCI6NTQ1NCwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU0MzM3Mzc0NH0.RU6ynAZcwQvdfygt_N_j2rb2lpsuyyROzdaLQg0emAg';
        //Sandcastle_Begin
        let viewer = new Cesium.Viewer('cesiumContainer');

        let redPolygon = viewer.entities.add({
            name: 'Red polygon on surface',
            polygon: {
                hierarchy: Cesium.Cartesian3.fromDegreesArray([-115.0, 37.0,
                    -115.0, 32.0,
                    -107.0, 33.0,
                    -102.0, 31.0,
                    -102.0, 35.0]),  // 逆时针方向。
                material: Cesium.Color.RED
            }
        });

        let greenPolygon = viewer.entities.add({
            name: 'Green extruded polygon',
            polygon: {
                hierarchy: Cesium.Cartesian3.fromDegreesArray([-108.0, 42.0,
                    -100.0, 42.0,
                    -104.0, 40.0]),  // (顺时针方向)平面(地面)模型。
                extrudedHeight: 500000.0,  // extrudedHeight,(未指定 height 时)(向上)挤压出的高度。
                material: Cesium.Color.GREEN,
                closeTop: false,  // 封顶,默认true。
                closeBottom: false  // 封底,默认true。
            }
        });

        let orangePolygon = viewer.entities.add({
            name: 'Orange polygon with per-position heights and outline',
            polygon: {
                hierarchy: Cesium.Cartesian3.fromDegreesArrayHeights([-108.0, 25.0, 100000,
                    -100.0, 25.0, 100000,
                    -100.0, 30.0, 100000,
                    -108.0, 30.0, 300000]),
                extrudedHeight: 0,
                perPositionHeight: true,  // 默认false(紧贴地面)。
                material: Cesium.Color.ORANGE.withAlpha(0.5),
                outline: true,
                outlineColor: Cesium.Color.BLACK
            }
        });

        let bluePolygon = viewer.entities.add({
            name: 'Blue polygon with holes',
            polygon: {
                hierarchy: {
                    positions: Cesium.Cartesian3.fromDegreesArray([-99.0, 30.0,
                        -85.0, 30.0,
                        -85.0, 40.0,
                        -99.0, 40.0]),
                    holes: [{
                        positions: Cesium.Cartesian3.fromDegreesArray([
                            -97.0, 31.0,
                            -97.0, 39.0,
                            -87.0, 39.0,
                            -87.0, 31.0
                        ]),
                        holes: [{
                            positions: Cesium.Cartesian3.fromDegreesArray([
                                -95.0, 33.0,
                                -89.0, 33.0,
                                -89.0, 37.0,
                                -95.0, 37.0
                            ]),
                            holes: [{
                                positions: Cesium.Cartesian3.fromDegreesArray([
                                    -93.0, 34.0,
                                    -91.0, 34.0,
                                    -91.0, 36.0,
                                    -93.0, 36.0
                                ])
                            }]
                        }]
                    }]
                },
                material: Cesium.Color.BLUE.withAlpha(0.5),
                height: 0,
                outline: true // height is required for outline to display
            }
        });

        let cyanPolygon = viewer.entities.add({
            name: 'Cyan vertical polygon with per-position heights and outline',
            polygon: {
                hierarchy: Cesium.Cartesian3.fromDegreesArrayHeights([
                    -90.0, 41.0, 0.0,
                    -85.0, 41.0, 500000.0,
                    -80.0, 41.0, 0.0
                ]),
                perPositionHeight: true,
                material: Cesium.Color.CYAN.withAlpha(0.5),
                outline: true,
                outlineColor: Cesium.Color.BLACK
            }
        });

        let purplePolygonUsingRhumbLines = viewer.entities.add({
            name: 'Purple polygon using rhumb lines with outline',
            polygon: {
                hierarchy: Cesium.Cartesian3.fromDegreesArray([-120.0, 45.0,
                    -80.0, 45.0,
                    -80.0, 55.0,
                    -120.0, 55.0]),
                height: 500000,
                extrudedHeight: 400000,  // extrudedHeight,(指定 height 时)多边形挤压面与椭球面之间的距离,以米为单位。
                // 挤压(出)面,是指靠近椭球(地球)面的那一个面。
                material: Cesium.Color.PURPLE,
                outline: true,
                outlineColor: Cesium.Color.MAGENTA,
                arcType: Cesium.ArcType.RHUMB
            }
        });

        viewer.zoomTo(viewer.entities);//Sandcastle_End
        Sandcastle.finishedLoading();
    }

    if (typeof Cesium !== 'undefined') {
        startup(Cesium);
    } else if (typeof require === 'function') {
        require(['Cesium'], startup);
    }
</script>
</body>
</html>



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值