顯示源代碼
                3D行政區(qū)域可視化
                 開(kāi)發(fā)文檔
                            <!DOCTYPE html>
                
                <html>
                  <head>
                    <meta charset="UTF-8" />
                    <meta
                      name="viewport"
                      content="initial-scale=1,maximum-scale=1,user-scalable=no"
                    />
                    <link
                      href="http://www.xawiki.com:9000/bigemap-gl.js/v1.1.0/Widgets/widgets.css"
                      rel="stylesheet"
                    />
                    <script src="http://www.xawiki.com:9000/bigemap-gl.js/v1.1.0/bigemap-gl.js"></script>
                    <style>
                      body {
                        margin: 0;
                        padding: 0;
                      }
                
                      #container {
                        position: absolute;
                        top: 0;
                        bottom: 0;
                        width: 100%;
                        background-image: url("/bmgl/3dksh/bj.jpg");
                        background-repeat: no-repeat;
                        background-size: 100%;
                      }
                
                      .bmgl-widget-credits {
                        display: none;
                      }
                    </style>
                    <title>part_test</title>
                  </head>
                  <body>
                    <div id="container"></div>
                
                    <script>
                      bmgl.Config.HTTP_URL = 'http://ua.bigemap.com:30081/bmsdk/';
                      var viewer = new bmgl.Viewer("container", {
                        mapId: "bigemap.dc-satellite",
                        requestRenderMode: false,
                        orderIndependentTranslucency: false,
                        contextOptions: {
                          webgl: {
                            alpha: true,
                          },
                        },
                      });
                      viewer.BMWidget.screenSpaceEventHandler.removeInputAction(
                        bmgl.ScreenSpaceEventType.LEFT_CLICK
                      );
                
                      var scene = viewer.scene;
                      var handler = new bmgl.ScreenSpaceEventHandler(scene.canvas);
                      var ellipsoid = scene.globe.ellipsoid; //得到當(dāng)前三維場(chǎng)景的橢球體
                
                      //關(guān)閉地圖元素
                      viewer.scene.globe.show = false;
                      viewer.scene.skyBox.show = false; //隱藏天空盒子
                      viewer.scene.backgroundColor = new bmgl.Color(0.0, 0.0, 0.0, 0.0); //隱藏黑色背景
                      viewer.scene.globe.baseColor = new bmgl.Color(0, 0, 0, 0); //替換球體默認(rèn)藍(lán)色
                      viewer.scene.globe.enableLighting = false; //隱藏太陽(yáng)
                      viewer.shadows = false;
                      viewer.scene.sun.show = false; //或者viewer.scene.sun.destroy();
                      viewer.scene.moon.show = false; //隱藏月亮
                      viewer.scene.skyAtmosphere.show = false; //大氣圈
                      viewer.scene.fog.enable = false; //霧
                
                      viewer.imageryLayers.remove(viewer.imageryLayers.get(0), false);
                
                      //加載省市
                      var promise = bmgl.KmlDataSource.load("/bmgl/3dksh/sichuan.kml");
                      promise
                        .then(function (dataSource) {
                          viewer.dataSources.add(dataSource);
                          //Get the array of entities
                          var entities = dataSource.entities.values;
                          var colorHash = {};
                          for (var i = 0; i < entities.length; i++) {
                            //For each entity, create a random color based on the state name.
                            //Some states have multiple entities, so we store the color in a
                            //hash so that we use the same color for the entire state.
                            var entity = entities[i];
                
                            if (entity.polygon) {
                              var name = entity.name;
                
                              viewer.entities.add({
                                polygon: {
                                  hierarchy: entity.polygon.hierarchy.getValue(),
                                  outline: true,
                                  material: new bmgl.ImageMaterialProperty({
                                    image: "/bmgl/3dksh/sc.png",
                                    repeat: new bmgl.Cartesian2(1, 1),
                                  }),
                                  extrudedHeight: 20000,
                                },
                              });
                            }
                          }
                          viewer.flyTo(viewer.entities);
                        })
                        .otherwise(function (error) {
                          //Display any errrors encountered while loading.
                          window.alert(error);
                        });
                
                      var promise = bmgl.KmlDataSource.load("/bmgl/3dksh/soncity.kml");
                      promise
                        .then(function (dataSource) {
                          viewer.dataSources.add(dataSource);
                          //Get the array of entities
                          var entities = dataSource.entities.values;
                          var colorHash = {};
                          for (var i = 0; i < entities.length; i++) {
                            //For each entity, create a random color based on the state name.
                            //Some states have multiple entities, so we store the color in a
                            //hash so that we use the same color for the entire state.
                            var entity = entities[i];
                
                            if (entity.polygon) {
                              var name = entity.name;
                
                              //畫(huà)多邊形
                              viewer.entities.add({
                                name: name,
                                type: "polygon",
                                polygon: {
                                  hierarchy: entity.polygon.hierarchy.getValue(),
                                  outline: true,
                                  material: new bmgl.Color(0, 0, 0, 0.1),
                                  extrudedHeight: 21000,
                                },
                              });
                
                              //畫(huà)邊界線
                              let xyzs = entity.polygon.hierarchy.getValue();
                
                              //添加標(biāo)注
                              drawLabel(xyzs.positions, name);
                
                              //畫(huà)線
                              let latlngs = [];
                              xyzs.positions.forEach((v) => {
                                let tmplatlng = xyz2latlng(v);
                                tmplatlng.forEach((l) => {
                                  latlngs.push(l);
                                });
                              });
                              drawLine(latlngs);
                            }
                          }
                          viewer.flyTo(viewer.entities);
                        })
                        .otherwise(function (error) {
                          //Display any errrors encountered while loading.
                          window.alert(error);
                        });
                
                      //記錄上一個(gè)點(diǎn)擊的entity
                      let lastentity = "";
                
                      handler.setInputAction(function (e) {
                        var entity = viewer.scene.pick(e.position);
                
                        console.log(entity);
                        console.log(lastentity);
                        if (entity != undefined) {
                          if (entity.id.type == "polygon") {
                            if (lastentity != "") {
                              lastentity.material = new bmgl.Color(0, 0, 0, 0.1);
                            }
                            lastentity = entity.id.polygon;
                            lastentity.material = new bmgl.Color(0.4, 0, 0, 0.8);
                            console.log(entity.id.name);
                          }
                        } else {
                          if (lastentity != "") {
                            lastentity.material = new bmgl.Color(0, 0, 0, 0.1);
                          }
                          lastentity = "";
                        }
                      }, bmgl.ScreenSpaceEventType.LEFT_CLICK);
                
                      function xyz2latlng(xyz, height = 20100) {
                        let wgs84 = ellipsoid.cartesianToCartographic(xyz);
                        let lng = bmgl.Math.toDegrees(wgs84.longitude);
                        let lat = bmgl.Math.toDegrees(wgs84.latitude);
                        return [lng, lat, height];
                      }
                
                      function drawLine(latlngs) {
                        var orangeOutlined = viewer.entities.add({
                          type: "line",
                          polyline: {
                            positions: bmgl.Cartesian3.fromDegreesArrayHeights(latlngs),
                            width: 5,
                            material: new bmgl.PolylineOutlineMaterialProperty({
                              color: bmgl.Color.ORANGE,
                              outlineWidth: 2,
                              outlineColor: bmgl.Color.BLACK,
                            }),
                          },
                        });
                      }
                
                      function drawLabel(polyPositions, name) {
                        let polyCenter = bmgl.BoundingSphere.fromPoints(polyPositions).center;
                        polyCenter = bmgl.Ellipsoid.WGS84.scaleToGeodeticSurface(polyCenter);
                
                        let xyz = new bmgl.Cartesian3(polyCenter.x, polyCenter.y, polyCenter.z);
                        let wgs84 = ellipsoid.cartesianToCartographic(xyz);
                        let lng = bmgl.Math.toDegrees(wgs84.longitude);
                        let lat = bmgl.Math.toDegrees(wgs84.latitude);
                        viewer.entities.add({
                          type: "label",
                          position: bmgl.Cartesian3.fromDegrees(lng, lat, 40000),
                          label: {
                            scale: 0.6,
                            showBackground: true,
                            backgroundColor: new bmgl.Color(0.165, 0.165, 0.165, 0.5),
                            fillColor: bmgl.Color.WHITE,
                            text: name,
                            disableDepthTestDistance: 900000,
                          },
                        });
                      }
                    </script>
                  </body>
                </html>
                        
                主站蜘蛛池模板: 国产精品高清一区二区三区| 日韩精品一区二区三区国语自制 | 欧美性猛交xxxx乱大交蜜桃| 啊昂…啊昂高h| www.日日夜夜| 好吊妞最新视频免费观看| 久久免费看少妇高潮V片特黄| 欧美日韩久久中文字幕| 公和我做好爽添厨房| 青青青青青草原| 国产精品午夜小视频观看| yy6080亚洲一级理论| 日本免费网站在线观看| 亚洲伊人色欲综合网| 用劲好爽快点要喷了视频| 国产一级片播放| 日本亚州视频在线八a| 在线中文字幕播放| 一道本在线播放| 日本性生活网站| 亚洲免费在线视频| 狠狠色丁香婷婷久久综合蜜芽| 国产亚av手机在线观看| 美女网站在线观看视频免费的| 天天做天天爱夜夜爽毛片毛片| 中文字幕在线观看第二页| 日韩精品无码久久一区二区三| 亚洲熟妇无码乱子av电影| 精品国产www| 国产伦子系列麻豆精品| 2020欧美极品hd18| 国内精品人妻无码久久久影院导航 | 李小璐三级在线视频| 亚洲精品无码久久久久秋霞| аⅴ中文在线天堂| 日韩一卡2卡3卡4卡| 亚洲成AV人综合在线观看| 男人的天堂视频网站清风阁| 嗯!啊!使劲用力在线观看| 高潮插的我好爽再干噢在线欢看 | 国产韩国精品一区二区三区|