1. 程式人生 > >cesium 1.52 demo _ Selection and Description.html

cesium 1.52 demo _ Selection and Description.html

<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Use correct character set. -->
    <meta charset="utf-8">
    <!-- Tell IE to use the latest, best version. -->
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <!-- Make the app on mobile take up the full browser screen and disable user scaling. -->
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <title>Selection and Description</title>

    <!-- The Cesium library. -->
    <script src="../ThirdParty/Cesium/Cesium.js"></script>
    <!-- Style our app. -->
    <style>
        @import url(../ThirdParty/Cesium/Widgets/widgets.css);
        html, body, #cesiumContainer {
            width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden;
        }
    </style>
</head>

<body>
    <div id="cesiumContainer"></div>
    <script>
        Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzNDhhYmQxOC1mYzMwLTRhYmEtOTI5Ny1iNGExNTQ3ZTZhODkiLCJpZCI6NTQ1NCwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU0MzM3Mzc0NH0.RU6ynAZcwQvdfygt_N_j2rb2lpsuyyROzdaLQg0emAg';
        let viewer = new Cesium.Viewer('cesiumContainer');
        let wyoming = viewer.entities.add({
            name : 'Wyoming',  // 實體名稱。
            polygon : {  // 實體型別
                hierarchy : Cesium.Cartesian3.fromDegreesArray([
                    -109.080842,45.002073,
                    -105.91517,45.002073,
                    -104.058488,44.996596,
                    -104.053011,43.002989,
                    -104.053011,41.003906,
                    -105.728954,40.998429,
                    -107.919731,41.003906,
                    -109.04798,40.998429,
                    -111.047063,40.998429,
                    -111.047063,42.000709,
                    -111.047063,44.476286,
                    -111.05254,45.002073]),  // 分層
                height : 0,  // 指定多邊形相對於橢球面的高度,預設0,此處用於啟用outline屬性。
                material : Cesium.Color.RED.withAlpha(0.5),  // 指定多邊形的填充顏色及透明度。
                outline : true,  // 是否顯示輪廓線。
                outlineColor : Cesium.Color.BLACK  // 輪廓線顏色
            }
        });
        viewer.zoomTo(wyoming);  // 檢視放大到wyoming實體。
        wyoming.description = '\
        <img\
          width="50%"\
          style="float:left; margin: 0 1em 1em 0;"\
          src="//cesiumjs.org/tutorials/Visualizing-Spatial-Data/images/Flag_of_Wyoming.svg"/>\
        <p>\
          Wyoming is a state in the mountain region of the Western \
          United States.\
        </p>\
        <p>\
          Wyoming is the 10th most extensive, but the least populous \
          and the second least densely populated of the 50 United \
          States. The western two thirds of the state is covered mostly \
          with the mountain ranges and rangelands in the foothills of \
          the eastern Rocky Mountains, while the eastern third of the \
          state is high elevation prairie known as the High Plains. \
          Cheyenne is the capital and the most populous city in Wyoming, \
          with a population estimate of 62,448 in 2013.\
        </p>\
        <p>\
          Source: \
          <a style="color: WHITE"\
            target="_blank"\
            href="http://en.wikipedia.org/wiki/Wyoming">Wikpedia</a>\
        </p>';
    </script>
</body>

</html>