+
liuyg
2022-01-04 128a3d4df3754e428cdb2c46bc1e10f074229256
src/components/mobilemap/index.vue
@@ -21,6 +21,8 @@
    <mobileGoTo></mobileGoTo>
    <!-- 实景窗口 -->
    <mobilePanorama></mobilePanorama>
    <!-- 盖住左下角 -->
    <div class="cover_mobileMap">智慧校园</div>
  </div>
</template>
<script>
@@ -240,6 +242,7 @@
      viewer.on(that.DC.SceneEventType.CAMERA_CHANGED, (e) => {
        //相机移动最后参数
        //控制高度
        let isSet = that.dimension == "3D" ? false : true;
        const height = Math.ceil(viewer.camera.positionCartographic.height);
        let conBack = (height) => {
          viewer.camera.setView({
@@ -265,10 +268,10 @@
        // if (height > 2000) {
        //   conBack(2000);
        // }
        if (height < 500) {
        if (height < 500 && isSet) {
          conBack(500);
        }
        if (height > 6000) {
        if (height > 6000 && isSet) {
          conBack(6000);
        }
      });
@@ -319,12 +322,9 @@
      //精细模型↓
      const tilesetLayer = new that.DC.TilesetLayer("tilesetLayer");
      viewer.addLayer(tilesetLayer);
      const tileset = new that.DC.Tileset(
        "http://data.mars3d.cn/3dtiles/max-shihua/tileset.json",
        {
          luminanceAtZenith: 0.5,
        }
      );
      const tileset = new that.DC.Tileset("/mx/tileset.json", {
        luminanceAtZenith: 0.5,
      });
      tilesetLayer.addOverlay(tileset);
      // tilesetLayer.show = false;
@@ -367,14 +367,13 @@
          e.position,
          [e.wgs84Position.lng, e.wgs84Position.lat],
          {
            name: e.layer._bid,
            address: e.layer.type,
            introduce: e.layer._id,
            name: e.overlay.attr.name,
            address: e.layer._id,
            introduce: e.overlay.attr.id,
            data: e,
          }
        );
      });
      //移动事件 高亮
      tileset.on(that.DC.MouseEventType.MOUSE_MOVE, (e) => {
        //高亮
        silhouetteBlue.selected = [];
        if (that.DC.Namespace.Cesium.defined(highlighted.feature)) {
@@ -398,45 +397,73 @@
          );
        }
      });
      //移动事件
      // tileset.on(that.DC.MouseEventType.MOUSE_MOVE, (e) => {
      //   silhouetteBlue.selected = [];
      //   if (that.DC.Namespace.Cesium.defined(highlighted.feature)) {
      //     highlighted.feature.color = highlighted.originalColor;
      //     highlighted.feature = undefined;
      //   }
      //   if (e.feature !== selected.feature) {
      //     silhouetteBlue.selected = [e.feature];
      //     highlighted.feature = e.feature;
      //     that.DC.Namespace.Cesium.Color.clone(
      //       e.feature.color,
      //       highlighted.originalColor
      //     );
      //     e.feature.color = that.DC.Namespace.Cesium.Color.fromBytes(
      //       155,
      //       255,
      //       175
      //     );
      //   }
      // });
      tilesetLayer["changesilhouetteBlue"] = () => {
        silhouetteBlue.selected = [];
      };
      tilesetLayer.show = false;
      // tilesetLayer.show = false;
      //精细模型↑
      // 2.5D贴图↓
      let usetowpointfive = () => {
        var provider =
          new that.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({
            url: "http://www.tdtfz.com/OneMapServer/rest/services/fzsw2019/MapServer/WMTS/tile/1.0.0/fzsw2019/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}",
            layer: "fzsw2019",
            style: "default",
            tileMatrixSetID: "default028mm",
            format: "image/jpgpng",
            tilingScheme: new that.DC.Namespace.Cesium.GeographicTilingScheme(),
            maximumLevel: 19,
            tileMatrixLabels: [
              "0",
              "1",
              "2",
              "3",
              "4",
              "5",
              "6",
              "7",
              "8",
              "9",
              "10",
              "11",
              "12",
              "13",
              "14",
              "15",
              "16",
              "17",
              "18",
              "19",
            ],
          // new that.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({
          //   url: "http://www.tdtfz.com/OneMapServer/rest/services/fzsw2019/MapServer/WMTS/tile/1.0.0/fzsw2019/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}",
          //   layer: "fzsw2019",
          //   style: "default",
          //   tileMatrixSetID: "default028mm",
          //   format: "image/jpgpng",
          //   tilingScheme: new that.DC.Namespace.Cesium.GeographicTilingScheme(),
          //   maximumLevel: 19,
          //   tileMatrixLabels: [
          //     "0",
          //     "1",
          //     "2",
          //     "3",
          //     "4",
          //     "5",
          //     "6",
          //     "7",
          //     "8",
          //     "9",
          //     "10",
          //     "11",
          //     "12",
          //     "13",
          //     "14",
          //     "15",
          //     "16",
          //     "17",
          //     "18",
          //     "19",
          //   ],
          // });
          new that.DC.Namespace.Cesium.ArcGisMapServerImageryProvider({
            url: "http://arcgis.jxpskj.com:6080/arcgis/rest/services/PingXiang25DMapDN/MapServer",
          });
        return viewer.imageryLayers.addImageryProvider(provider);
      };
@@ -444,52 +471,44 @@
      const newLayer = usetowpointfive();
      // 2.5D贴图↑
      let startPoint;
      if (false) {
      if (true) {
        startPoint = () => {
          viewer.flyTo(tileset);
          // that.$store.dispatch("mapFlyTo", {
          //   //飞入
          //   lntLat: [115.87988885, 28.72502592, 2100],
          //   // lntLat: [115.87186406, 28.74449337, 1200],
          //   // lntLat: [121.50492752204283, 31.21567802276832, 2530],
          //   heading: 0,
          //   pitch: -45,
          //   roll: 0,
          //   noOpen: true,
          // });
          let doit2 = (int) => {
            viewer.camera.setView({
              // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
              // fromDegrees()方法,将经纬度和高程转换为世界坐标
              destination: that.DC.Namespace.Cesium.Cartesian3.fromDegrees(
                // 114.0351,
                // 27.6314,
                // 200.0
                int[0],
                int[1],
                int[2]
              ),
              orientation: {
                // 指向
                heading: that.DC.Namespace.Cesium.Math.toRadians(108),
                // 视角
                pitch: that.DC.Namespace.Cesium.Math.toRadians(-26.46),
                roll: 0.0,
              },
            });
          };
          that.dimension == "2.5D"
            ? doit2([114.03928791, 27.62954732, 360.0])
            : // : doit([116.39038494750986, 39.902393222208644, 330.0]);
              // doit("建模");
              doit2([114.0351, 27.6314, 300.0]);
        };
        setTimeout((res) => {
          //转圈
          that.$store.dispatch("mapFlyTo", {
            lntLat: [111.25036579, 34.83767277, 11443175.85],
            heading: 0,
            pitch: -90,
            roll: 0,
            noOpen: true,
            fn: function () {
              // viewer.flyTo(tileset);
              // viewer.flyTo(provider);
              //飞入起始点
              // that.$store.dispatch("mapFlyTo", {
              //   lntLat: [115.87186406, 28.74449337, 1200],
              //   heading: 0,
              //   pitch: -45,
              //   roll: 0,
              //   noOpen: true,
              // });
              startPoint();
            },
          });
          // viewer.flyTo(tileset);
        }, 2500);
      } else {
        startPoint = (val) => {
          // viewer.zoomToPosition(
          //   new DC.Position(115.86798885, 28.72502592, 2100, 0, -45)
          // );
          let doit = (int) => {
            if (val == 1) {
            if (int == "建模") {
              viewer.flyTo(tileset);
            } else if (val == 1) {
              viewer.camera.setView({
                // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                // fromDegrees()方法,将经纬度和高程转换为世界坐标
@@ -514,6 +533,7 @@
                },
              });
            } else {
              // console.log(123456);
              that.$store.dispatch("mapFlyTo", {
                lntLat: [+int[0] + 0.012, int[1], int[2]],
                // 指向
@@ -525,11 +545,14 @@
              });
            }
          };
          // [116.36618337, 27.95911915, 2000.0]
          that.dimension == "2.5D"
            ? doit([116.36618337, 27.95911915, 2000.0])
            : doit([117.08513731, 31.64790556, 600.0]);
            ? doit([114.03928791, 27.62954732, 360.0])
            : // : doit([116.39038494750986, 39.902393222208644, 330.0]);
              doit("建模");
          // doit(114.03925, 27.6265, 360.0);
        };
        startPoint(1);
        // startPoint(1);
      }
      //传递默认位置
      that.$store.commit("MSET_MORENWEIZHI", startPoint);
@@ -591,7 +614,38 @@
      viewer.zoomController.enable = true;
      viewer.locationBar.enable = false;
      viewer.distanceLegend.enable = false;
      if (true) {
      //判断默认维度
      //原本默认是2.5d  改为3d默认时做出改变
      if (that.dimension == "2.5D") {
        that.$store.commit("MSET_DIMENSION", "2.5D"); //切换2.5D设置
      } else if (that.dimension == "3D") {
        // setTimeout((res) => {
        //   that.$store.dispatch("mapFlyTo", {
        //     lntLat: [111.25036579, 34.83767277, 11443175.85],
        //     heading: 0,
        //     pitch: -90,
        //     roll: 0,
        //     noOpen: true,
        //     fn: function () {
        // viewer.flyTo(tileset);
        // viewer.flyTo(provider);
        //飞入起始点
        // that.$store.dispatch("mapFlyTo", {
        //   lntLat: [115.87186406, 28.74449337, 1200],
        //   heading: 0,
        //   pitch: -45,
        //   roll: 0,
        //   noOpen: true,
        // });
        // startPoint();
        that.$store.commit("MSET_DIMENSION", "3D"); //切换3D设置
        //     },
        //   });
        // }, 2000);
      }
      if (false) {
        //镜头改变示例
        // viewer.scene.screenSpaceCameraController.enableZoom = false; //控制视角缩放
        // viewer.scene.screenSpaceCameraController.enableTilt = false; //控制视角旋转
        // viewer.scene.screenSpaceCameraController.minimumZoomDistance = 200; //最小缩放
@@ -633,7 +687,7 @@
};
</script>
<style lang='scss' scope>
<style lang="scss" scope>
#mobile-viewer-container {
  width: 100%;
  height: 100%;