From 1b65bf157e9d1852bf819bcebcdbf596b77ae6b9 Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Tue, 18 Jan 2022 14:11:36 +0800
Subject: [PATCH] +点击建筑弹窗加绿布

---
 src/components/mobilemap/index.vue |  205 +++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 165 insertions(+), 40 deletions(-)

diff --git a/src/components/mobilemap/index.vue b/src/components/mobilemap/index.vue
index 330280f..99a655e 100644
--- a/src/components/mobilemap/index.vue
+++ b/src/components/mobilemap/index.vue
@@ -14,18 +14,26 @@
     <mobileCortrolSearch ref="mobileCortrolSearch"></mobileCortrolSearch>
     <!-- 控制↑ -->
     <!-- 控制大弹窗的弹窗 -->
-    <mobilePopupOurAfter v-if="mBigPopupAfter"></mobilePopupOurAfter>
+    <!-- v-if="mBigPopupAfter" -->
+    <mobilePopupOurAfter></mobilePopupOurAfter>
     <!-- 大弹窗 -->
     <mobilePopupOur :style="[bigPopup]" v-if="mBigPopup"></mobilePopupOur>
     <!-- 测试-跳转位置 -->
     <mobileGoTo></mobileGoTo>
     <!-- 实景窗口 -->
     <mobilePanorama></mobilePanorama>
+    <!-- 退出导航 -->
+    <mobileCloseRouter></mobileCloseRouter>
+    <!-- 退出活动 -->
+    <mobileCloseRouterMany></mobileCloseRouterMany>
+    <!-- 活动窗口 -->
+    <!-- <mobileActivity></mobileActivity> -->
     <!-- 盖住左下角 -->
-    <div class="cover_mobileMap">智慧校园</div>
+    <div class="cover_mobileMap">智慧社区</div>
   </div>
 </template>
 <script>
+import axios from "axios";
 import { mapGetters } from "vuex";
 export default {
   name: "mobilemapBox",
@@ -72,6 +80,7 @@
         [116.39585177, 27.93945304, 100],
         [116.41526036, 27.95352217, 100],
       ],
+      areaLayer: null,
     };
   },
   computed: {
@@ -85,6 +94,7 @@
       "MobileWindowsHideFixed",
       "dimension",
       "dimensionData",
+      "areaLayer", //绿布
     ]),
   },
   watch: {
@@ -194,11 +204,10 @@
           url: "https://webmap-tile.sf-express.com/MapTileService/rt?fetchtype=static&x={x}&y={y}&z={z}&project=sfmap&pic_size=256&pic_type=png8&data_name=361100&data_format=merged-dat&data_type=normal", // 行政区划
         }
       );
-      viewer.addBaseLayer(baselayer, {
-        iconUrl: "examples/images/icon/img.png",
-        name: "影像",
-      });
-
+      // viewer.addBaseLayer(baselayer, {
+      //   iconUrl: "examples/images/icon/img.png",
+      //   name: "影像",
+      // });
       // eslint-disable-next-line camelcase
       // const baselayer_shaded = DC.ImageryLayerFactory.createArcGisImageryLayer({
       //   url: "http://services.arcgisonline.com/arcgis/rest/services/World_Shaded_Relief/MapServer",
@@ -268,11 +277,11 @@
         // if (height > 2000) {
         //   conBack(2000);
         // }
-        if (height < 500 && isSet) {
-          conBack(500);
+        if (height < 0 && isSet) {
+          conBack(0);
         }
-        if (height > 6000 && isSet) {
-          conBack(6000);
+        if (height > 4000 && isSet) {
+          conBack(4000);
         }
       });
 
@@ -325,7 +334,8 @@
       const tileset = new that.DC.Tileset("/mx/tileset.json", {
         luminanceAtZenith: 0.5,
       });
-      tilesetLayer.addOverlay(tileset);
+
+      // tilesetLayer.addOverlay(tileset);
       // tilesetLayer.show = false;
 
       let silhouetteBlue =
@@ -422,9 +432,9 @@
       //     );
       //   }
       // });
-      tilesetLayer["changesilhouetteBlue"] = () => {
-        silhouetteBlue.selected = [];
-      };
+      // tilesetLayer["changesilhouetteBlue"] = () => {
+      //   silhouetteBlue.selected = [];
+      // };
       // tilesetLayer.show = false;
       //精细模型↑
 
@@ -462,18 +472,126 @@
           //     "19",
           //   ],
           // });
-          new that.DC.Namespace.Cesium.ArcGisMapServerImageryProvider({
-            url: "http://arcgis.jxpskj.com:6080/arcgis/rest/services/PingXiang25DMapDN/MapServer",
+          // new that.DC.Namespace.Cesium.ArcGisMapServerImageryProvider({
+          //   url: "http://arcgis.jxpskj.com:6080/arcgis/rest/services/PingXiang25DMapDN/MapServer",
+          // });
+          new that.DC.Namespace.Cesium.UrlTemplateImageryProvider({
+            url: "/wp/{z}/{x}/{y}.png",
+            fileExtension: "png",
           });
         return viewer.imageryLayers.addImageryProvider(provider);
       };
 
       const newLayer = usetowpointfive();
+      //2.5d贴图事件
+      const layerGroup = new that.DC.LayerGroup("modelBox");
+      viewer.addLayerGroup(layerGroup);
+
+      let areaLayer = new that.DC.VectorLayer("areaLayer");
+      layerGroup.addLayer(areaLayer);
+      axios
+        .get(
+          "http://arcgis.jxpskj.com:6080/arcgis/rest/services/lxxqwxq/MapServer/0/query?where=1%3D1&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=*&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&returnTrueCurves=false&resultOffset=&resultRecordCount=&f=pjson"
+        )
+        .then((resultData) => {
+          resultData.data.features.forEach((item) => {
+            item.geometry.rings[0].forEach((it) => {
+              it = it.join(",");
+            });
+
+            item.geometry.rings[0] = item.geometry.rings[0].join(";");
+
+            const polygon = new that.DC.Polygon(item.geometry.rings[0]);
+            polygon.attr = item.attributes;
+
+            polygon.setStyle({
+              material: that.DC.Namespace.Cesium.Color.fromBytes(
+                255,
+                255,
+                255,
+                1
+              ),
+            });
+
+            areaLayer.addOverlay(polygon);
+          });
+
+          areaLayer.show = true;
+        });
+      that.$store.commit("MSET_areaLayer", areaLayer);
+      var select = {
+        overlay: undefined,
+        color: undefined,
+      };
+      viewer.on(that.DC.MouseEventType.CLICK, (e) => {
+        // console.log(e);
+        if (e.overlay != undefined && e.layer.id == "areaLayer") {
+          if (select.overlay != undefined) {
+            if (e.overlay != select.overlay) {
+              select.overlay.setStyle({
+                material: select.color,
+                outline: false,
+              });
+
+              select.overlay = undefined;
+              select.color = undefined;
+            }
+          }
+
+          if (select.overlay == undefined) {
+            select.overlay = e.overlay;
+
+            select.color = e.overlay._style.material;
+            select.overlay.setStyle({
+              outline: true,
+              outlineColor: that.DC.Namespace.Cesium.Color.fromBytes(
+                3,
+                255,
+                13,
+                255
+              ), // 边框颜色
+              outlineWidth: 10, // 边框大小,
+              height: 0.01,
+              material: that.DC.Namespace.Cesium.Color.fromBytes(
+                108,
+                245,
+                113,
+                158
+              ),
+            });
+          }
+          // 定制化窗体
+          that.openPopupS(
+            {},
+            [e.wgs84SurfacePosition.lng, e.wgs84SurfacePosition.lat],
+            {
+              name: "楼栋号:" + e.overlay.attr["楼栋号"],
+              bgImg:
+                "http://223.82.109.183:2081/zhxy/upload/20220105/3c05dd70a9eac17b7e49afbfc7b1b68e.png",
+              address: "",
+              introduce: "",
+              data: e,
+              lntLat: [e.wgs84SurfacePosition.lng, e.wgs84SurfacePosition.lat],
+            }
+          );
+        } else {
+          if (select.overlay != undefined) {
+            select.overlay.setStyle({
+              material: select.color,
+              outline: false,
+            });
+
+            select.overlay = undefined;
+            select.color = undefined;
+          }
+        }
+      });
+
       // 2.5D贴图↑
       let startPoint;
       if (true) {
         startPoint = () => {
-          let doit2 = (int) => {
+          let doit2 = (int, h) => {
             viewer.camera.setView({
               // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
               // fromDegrees()方法,将经纬度和高程转换为世界坐标
@@ -487,18 +605,25 @@
               ),
               orientation: {
                 // 指向
-                heading: that.DC.Namespace.Cesium.Math.toRadians(108),
+                heading: that.DC.Namespace.Cesium.Math.toRadians(h[0]),
                 // 视角
-                pitch: that.DC.Namespace.Cesium.Math.toRadians(-26.46),
-                roll: 0.0,
+                pitch: that.DC.Namespace.Cesium.Math.toRadians(h[1]),
+                roll: h[2],
               },
             });
           };
           that.dimension == "2.5D"
-            ? doit2([114.03928791, 27.62954732, 360.0])
+            ? doit2(
+                [114.03928791, 27.62954732, 360.0],
+                [
+                  that.dimensionData.heading,
+                  that.dimensionData.pitch,
+                  that.dimensionData.roll,
+                ]
+              )
             : // : doit([116.39038494750986, 39.902393222208644, 330.0]);
               // doit("建模");
-              doit2([114.0351, 27.6314, 300.0]);
+              doit2([114.0351, 27.6314, 300.0], [108, -26.46, 0.0]);
         };
       } else {
         startPoint = (val) => {
@@ -571,29 +696,29 @@
 
       //瀑布流↓
       const wallLayer = new that.DC.VectorLayer("wallLayer");
-      viewer.addLayer(wallLayer);
-      var arr = that.wallArr;
-      arr.forEach((item) => {
-        item = item.join(",");
-      });
-      arr = arr.join(";");
-      const wall = new that.DC.Wall(arr);
-      wall.setStyle({
-        material: new that.DC.WallTrailMaterialProperty({
-          color: that.DC.Namespace.Cesium.Color.fromBytes(0, 142, 255, 150),
-          // color: that.DC.Color.DEEPSKYBLUE,
-          speed: 4,
-        }),
-      });
-      wallLayer.addOverlay(wall);
+      // viewer.addLayer(wallLayer);
+      // var arr = that.wallArr;
+      // arr.forEach((item) => {
+      //   item = item.join(",");
+      // });
+      // arr = arr.join(";");
+      // const wall = new that.DC.Wall(arr);
+      // wall.setStyle({
+      //   material: new that.DC.WallTrailMaterialProperty({
+      //     color: that.DC.Namespace.Cesium.Color.fromBytes(0, 142, 255, 150),
+      //     // color: that.DC.Color.DEEPSKYBLUE,
+      //     speed: 4,
+      //   }),
+      // });
+      // wallLayer.addOverlay(wall);
 
-      viewer.use(new that.DC.Measure());
+      // viewer.use(new that.DC.Measure());
       //瀑布流↑
 
       // 传入store
       that.$store.commit("MSET_MODEOLS", {
         tilesetLayer: tilesetLayer,
-        tileset: tileset,
+        // tileset: tileset,
         newLayer: newLayer,
         wallLayer: wallLayer,
         usetowpointfive: usetowpointfive,

--
Gitblit v1.9.3