shuishen
2022-03-11 ead73b4e3a20d15d03ed662fe1850393a4decfa3
src/components/mobilemap/index.vue
@@ -45,7 +45,6 @@
            butbut: null,
            heights: 0,
            heights1: 0,
            DC: '',
            bigPopup: {
                width: 0,
                height: 0
@@ -87,14 +86,15 @@
                [116.41526036, 27.95352217, 100]
            ],
            areaLayer: null,
            mapCenter: [115.871863, 28.743861, 400.0],
            mapCenter: [115.871863, 28.743861, 160.0],
            //   mapCenter: [114.04062292 - 0.00035, 27.62666834 + 0.0025, 160.0],
            // 控制4层缩放
            onelayerNum: 80,
            towlayerNum: 120,
            threelayerNum: 160,
            forlayerNum: 200,
            forlayerNum: null,
            intervallayerNum: 20,
            frislayertHeight: 160 // 默认高度
            frislayertHeight: 120 // 默认高度
            // onelayerNum: 80,
            // towlayerNum: 200,
            // threelayerNum: 320,
@@ -134,9 +134,6 @@
    },
    mounted () {
        // return;
        var DC = global.DC
        this.DC = DC
        var that = this
        let viewer
@@ -200,7 +197,7 @@
        }
        function initViewer () {
            viewer = new DC.Viewer('mobile-viewer-container', {
            viewer = new global.DC.Viewer('mobile-viewer-container', {
                contextOptions: {
                    webgl: {
                        stencil: true,
@@ -219,8 +216,8 @@
            // const baselayer = DC.ImageryLayerFactory.createArcGisImageryLayer({
            //   url: "http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
            // });
            const baselayer = that.DC.ImageryLayerFactory.createImageryLayer(
                that.DC.ImageryType.XYZ,
            const baselayer = global.DC.ImageryLayerFactory.createImageryLayer(
                global.DC.ImageryType.XYZ,
                {
                    // url: 'https://webmap-tile.sf-express.com/MapTileService/rt?x={col}&y={row}&z={level}'
@@ -259,7 +256,7 @@
            // });
            // 地图移动事件
            viewer.on(DC.MouseEventType.MOUSE_MOVE, (e) => {
            viewer.on(global.DC.MouseEventType.MOUSE_MOVE, (e) => {
                if (!that.iconHide) {
                    that.$store.commit('MSET_ICONHIDE', true)
                }
@@ -270,24 +267,24 @@
                // console.log(height);
            })
            // viewer.on(that.DC.SceneEventType.CAMERA_MOVE_END, (e) => {
            viewer.on(that.DC.SceneEventType.CAMERA_CHANGED, (e) => {
            // viewer.on(global.DC.SceneEventType.CAMERA_MOVE_END, (e) => {
            viewer.on(global.DC.SceneEventType.CAMERA_CHANGED, (e) => {
                // 相机移动最后参数
                // 控制高度
                const isSet = that.dimension != '3D'
                const height = Math.ceil(viewer.camera.positionCartographic.height)
                const conBack = (height) => {
                    viewer.camera.setView({
                        destination: that.DC.Namespace.Cesium.Cartesian3.fromRadians(
                        destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                            viewer.camera.positionCartographic.longitude,
                            viewer.camera.positionCartographic.latitude,
                            height
                        ),
                        orientation: {
                            heading: that.DC.Namespace.Cesium.Math.toRadians(
                            heading: global.DC.Namespace.Cesium.Math.toRadians(
                                that.dimensionData.heading
                            ), // 方向
                            pitch: that.DC.Namespace.Cesium.Math.toRadians(
                            pitch: global.DC.Namespace.Cesium.Math.toRadians(
                                that.dimensionData.pitch
                            ), // 倾斜角度
                            roll: that.dimensionData.roll
@@ -318,24 +315,25 @@
                // if (height > 200 && isSet) {
                //   conBack(200);
                // }
                if (height > that.forlayerNum && isSet) {
                    conBack(that.forlayerNum)
                const usMun = that.forlayerNum ? that.forlayerNum : that.threelayerNum
                if (height > usMun && isSet) {
                    conBack(usMun)
                }
            })
            // 按钮事件
            const butSetViews = (num) => {
                viewer.camera.flyTo({
                    destination: that.DC.Namespace.Cesium.Cartesian3.fromRadians(
                    destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                        viewer.camera.positionCartographic.longitude,
                        viewer.camera.positionCartographic.latitude,
                        num
                    ),
                    orientation: {
                        // 指向
                        heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0),
                        heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                        // 视角
                        pitch: that.DC.Namespace.Cesium.Math.toRadians(-90),
                        pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                        roll: 0.0
                    },
                    duration: 0.5 // 定位的时间间隔
@@ -363,9 +361,11 @@
                            // if (height > 100) {
                            //   butSetViews(80);
                            // }
                            if (height > that.forlayerNum - that.intervallayerNum) {
                                butSetViews(that.threelayerNum)
                                return
                            if (that.forlayerNum) {
                                if (height > that.forlayerNum - that.intervallayerNum) {
                                    butSetViews(that.threelayerNum)
                                    return
                                }
                            }
                            if (height > that.threelayerNum - that.intervallayerNum) {
@@ -410,11 +410,13 @@
                                butSetViews(that.threelayerNum)
                            }
                            if (
                                height > that.threelayerNum - that.intervallayerNum &&
                                height < that.forlayerNum - that.intervallayerNum
                            ) {
                                butSetViews(that.forlayerNum)
                            if (that.forlayerNum) {
                                if (
                                    height > that.threelayerNum - that.intervallayerNum &&
                                    height < that.forlayerNum - that.intervallayerNum
                                ) {
                                    butSetViews(that.forlayerNum)
                                }
                            }
                        }
                    }
@@ -430,16 +432,16 @@
                }
                var setViews = (num) => {
                    viewer.camera.flyTo({
                        destination: that.DC.Namespace.Cesium.Cartesian3.fromRadians(
                        destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                            viewer.camera.positionCartographic.longitude,
                            viewer.camera.positionCartographic.latitude,
                            num
                        ),
                        orientation: {
                            // 指向
                            heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0),
                            heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                            // 视角
                            pitch: that.DC.Namespace.Cesium.Math.toRadians(-90),
                            pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                            roll: 0.0
                        },
                        duration: 0.5 // 定位的时间间隔
@@ -447,7 +449,7 @@
                    overii()
                }
                var isCameraTime = null
                viewer.on(that.DC.SceneEventType.CAMERA_CHANGED, (e) => {
                viewer.on(global.DC.SceneEventType.CAMERA_CHANGED, (e) => {
                    if (that.dimension == '2.5D') {
                        // console.log(e);
                        const height = Math.ceil(viewer.camera.positionCartographic.height)
@@ -457,7 +459,6 @@
                        ii++
                        cutHeight = height - startHeight
                        // console.log(cutHeight);
                        console.log(height, 'see')
                        that.heights = height
                        that.heights1 = cutHeight
                        // return;
@@ -498,11 +499,13 @@
                                        ) {
                                            setViews(that.threelayerNum)
                                        }
                                        if (
                                            height >= that.threelayerNum + 2 &&
                                            height < that.forlayerNum
                                        ) {
                                            setViews(that.forlayerNum)
                                        if (that.forlayerNum) {
                                            if (
                                                height >= that.threelayerNum + 2 &&
                                                height < that.forlayerNum
                                            ) {
                                                setViews(that.forlayerNum)
                                            }
                                        }
                                    }
                                    // 放大
@@ -519,11 +522,13 @@
                                    //     setViews(80);
                                    //   }
                                    if (cutHeight < -2) {
                                        if (
                                            height <= that.forlayerNum &&
                                            height > that.threelayerNum - 2
                                        ) {
                                            setViews(that.threelayerNum)
                                        if (that.forlayerNum) {
                                            if (
                                                height <= that.forlayerNum &&
                                                height > that.threelayerNum - 2
                                            ) {
                                                setViews(that.threelayerNum)
                                            }
                                        }
                                        if (
                                            height <= that.threelayerNum - 2 &&
@@ -589,9 +594,9 @@
            // 白模型↑
            // 精细模型↓
            const tilesetLayer = new that.DC.TilesetLayer('tilesetLayer')
            const tilesetLayer = new global.DC.TilesetLayer('tilesetLayer')
            viewer.addLayer(tilesetLayer)
            const tileset = new that.DC.Tileset('/mx/tileset.json', {
            const tileset = new global.DC.Tileset('/mx/tileset.json', {
                luminanceAtZenith: 0.5
            })
@@ -599,37 +604,34 @@
            // tilesetLayer.show = false;
            const silhouetteBlue =
                that.DC.Namespace.Cesium.PostProcessStageLibrary.createEdgeDetectionStage()
            silhouetteBlue.uniforms.color = that.DC.Namespace.Cesium.Color.fromBytes(
                9,
                162,
                40
            )
                global.DC.Namespace.Cesium.PostProcessStageLibrary.createEdgeDetectionStage()
            silhouetteBlue.uniforms.color =
                global.DC.Namespace.Cesium.Color.fromBytes(9, 162, 40)
            silhouetteBlue.uniforms.length = 0.01
            silhouetteBlue.selected = []
            viewer.scene.postProcessStages.add(
                that.DC.Namespace.Cesium.PostProcessStageLibrary.createSilhouetteStage([
                    silhouetteBlue
                ])
                global.DC.Namespace.Cesium.PostProcessStageLibrary.createSilhouetteStage(
                    [silhouetteBlue]
                )
            )
            var highlighted = {
                feature: undefined,
                originalColor: new that.DC.Namespace.Cesium.Color()
                originalColor: new global.DC.Namespace.Cesium.Color()
            }
            var selected = {
                feature: undefined,
                originalColor: new that.DC.Namespace.Cesium.Color()
                originalColor: new global.DC.Namespace.Cesium.Color()
            }
            // 点击事件
            tileset.on(DC.MouseEventType.CLICK, (e) => {
            tileset.on(global.DC.MouseEventType.CLICK, (e) => {
                viewer.scene.globe.depthTestAgainstTerrain = false
                // console.log(e);
                viewer.flyToPosition(
                    new that.DC.Position(115.87186406, 28.74449337, 1800, 0, 45, 0)
                    new global.DC.Position(115.87186406, 28.74449337, 1800, 0, 45, 0)
                )
                // 定制化窗体
@@ -646,7 +648,7 @@
                // 高亮
                silhouetteBlue.selected = []
                if (that.DC.Namespace.Cesium.defined(highlighted.feature)) {
                if (global.DC.Namespace.Cesium.defined(highlighted.feature)) {
                    highlighted.feature.color = highlighted.originalColor
                    highlighted.feature = undefined
                }
@@ -656,11 +658,11 @@
                    highlighted.feature = e.feature
                    that.DC.Namespace.Cesium.Color.clone(
                    global.DC.Namespace.Cesium.Color.clone(
                        e.feature.color,
                        highlighted.originalColor
                    )
                    e.feature.color = that.DC.Namespace.Cesium.Color.fromBytes(
                    e.feature.color = global.DC.Namespace.Cesium.Color.fromBytes(
                        155,
                        255,
                        175
@@ -668,10 +670,10 @@
                }
            })
            // 移动事件
            // tileset.on(that.DC.MouseEventType.MOUSE_MOVE, (e) => {
            // tileset.on(global.DC.MouseEventType.MOUSE_MOVE, (e) => {
            //   silhouetteBlue.selected = [];
            //   if (that.DC.Namespace.Cesium.defined(highlighted.feature)) {
            //   if (global.DC.Namespace.Cesium.defined(highlighted.feature)) {
            //     highlighted.feature.color = highlighted.originalColor;
            //     highlighted.feature = undefined;
            //   }
@@ -681,11 +683,11 @@
            //     highlighted.feature = e.feature;
            //     that.DC.Namespace.Cesium.Color.clone(
            //     global.DC.Namespace.Cesium.Color.clone(
            //       e.feature.color,
            //       highlighted.originalColor
            //     );
            //     e.feature.color = that.DC.Namespace.Cesium.Color.fromBytes(
            //     e.feature.color = global.DC.Namespace.Cesium.Color.fromBytes(
            //       155,
            //       255,
            //       175
@@ -701,13 +703,13 @@
            // 2.5D贴图↓
            const usetowpointfive = () => {
                var provider =
                    // new that.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({
                    // new global.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(),
                    //   tilingScheme: new global.DC.Namespace.Cesium.GeographicTilingScheme(),
                    //   maximumLevel: 19,
                    //   tileMatrixLabels: [
                    //     "0",
@@ -732,10 +734,10 @@
                    //     "19",
                    //   ],
                    // });
                    // new that.DC.Namespace.Cesium.ArcGisMapServerImageryProvider({
                    // new global.DC.Namespace.Cesium.ArcGisMapServerImageryProvider({
                    //   url: "http://arcgis.jxpskj.com:6080/arcgis/rest/services/PingXiang25DMapDN/MapServer",
                    // });
                    new that.DC.Namespace.Cesium.UrlTemplateImageryProvider({
                    new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({
                        url: '/wp/{z}/{x}/{y}.png',
                        fileExtension: 'png'
                    })
@@ -744,10 +746,10 @@
            const newLayer = usetowpointfive()
            // 2.5d贴图事件
            const layerGroup = new that.DC.LayerGroup('modelBox')
            const layerGroup = new global.DC.LayerGroup('modelBox')
            viewer.addLayerGroup(layerGroup)
            const areaLayer = new that.DC.VectorLayer('areaLayer')
            const areaLayer = new global.DC.VectorLayer('areaLayer')
            layerGroup.addLayer(areaLayer)
            axios
                .get(
@@ -761,11 +763,11 @@
                        item.geometry.rings[0] = item.geometry.rings[0].join(';')
                        const polygon = new that.DC.Polygon(item.geometry.rings[0])
                        const polygon = new global.DC.Polygon(item.geometry.rings[0])
                        polygon.attr = item.attributes
                        polygon.setStyle({
                            material: that.DC.Namespace.Cesium.Color.fromBytes(
                            material: global.DC.Namespace.Cesium.Color.fromBytes(
                                255,
                                255,
                                255,
@@ -783,7 +785,7 @@
            //   overlay: undefined,
            //   color: undefined,
            // };
            viewer.on(that.DC.MouseEventType.CLICK, (e) => {
            viewer.on(global.DC.MouseEventType.CLICK, (e) => {
                // console.log(e);
                if (e.overlay != undefined && e.layer.id == 'areaLayer') {
                    if (that.areaLayerSelect.overlay != undefined) {
@@ -803,7 +805,7 @@
                        that.areaLayerSelect.color = e.overlay._style.material
                        that.areaLayerSelect.overlay.setStyle({
                            outline: true,
                            outlineColor: that.DC.Namespace.Cesium.Color.fromBytes(
                            outlineColor: global.DC.Namespace.Cesium.Color.fromBytes(
                                3,
                                255,
                                13,
@@ -811,7 +813,7 @@
                            ), // 边框颜色
                            outlineWidth: 10, // 边框大小,
                            height: 0.01,
                            material: that.DC.Namespace.Cesium.Color.fromBytes(
                            material: global.DC.Namespace.Cesium.Color.fromBytes(
                                108,
                                245,
                                113,
@@ -883,7 +885,7 @@
                        viewer.camera.setView({
                            // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                            // fromDegrees()方法,将经纬度和高程转换为世界坐标
                            destination: that.DC.Namespace.Cesium.Cartesian3.fromDegrees(
                            destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
                                // 114.0351,
                                // 27.6314,
                                // 200.0
@@ -893,9 +895,9 @@
                            ),
                            orientation: {
                                // 指向
                                heading: that.DC.Namespace.Cesium.Math.toRadians(h[0]),
                                heading: global.DC.Namespace.Cesium.Math.toRadians(h[0]),
                                // 视角
                                pitch: that.DC.Namespace.Cesium.Math.toRadians(h[1]),
                                pitch: global.DC.Namespace.Cesium.Math.toRadians(h[1]),
                                roll: h[2]
                            }
                        })
@@ -933,24 +935,24 @@
            // console.log(currentViewRect, 78);
            // 瀑布流↓
            const wallLayer = new that.DC.VectorLayer('wallLayer')
            const wallLayer = new global.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);
            // const wall = new global.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,
            //   material: new global.DC.WallTrailMaterialProperty({
            //     color: global.DC.Namespace.Cesium.Color.fromBytes(0, 142, 255, 150),
            //     // color: global.DC.Color.DEEPSKYBLUE,
            //     speed: 4,
            //   }),
            // });
            // wallLayer.addOverlay(wall);
            // viewer.use(new that.DC.Measure());
            // viewer.use(new global.DC.Measure());
            // 瀑布流↑
            // 传入store
@@ -983,7 +985,7 @@
                that.$store.commit('set_frislayertHeight', that.frislayertHeight) // 送入默认弹窗高度
                that.$store.commit('set_zoomRange', [
                    that.onelayerNum,
                    that.forlayerNum
                    that.forlayerNum ? that.forlayerNum : that.threelayerNum
                ]) // 送入移动端缩放范围
                that.$store.commit('MSET_DIMENSION', '2.5D') // 切换2.5D设置
            } else if (that.dimension == '3D') {
@@ -1016,7 +1018,7 @@
            viewer.scene.screenSpaceCameraController._maximumZoomRate = 5906376272000
        }
        DC.ready(initViewer)
        global.DC.ready(initViewer)
        setTimeout(() => {
            that.butbut()
@@ -1051,7 +1053,7 @@
                        position: {},
                        lntLat: [+that.urlParameterData.jd, +that.urlParameterData.wd],
                        query: {
                            introduce: '自定义标签',
                            introduce: '暂无内容',
                            address: '',
                            ...(that.urlParameterData || {}),
                            lntLat: [+that.urlParameterData.jd, +that.urlParameterData.wd]
@@ -1059,6 +1061,33 @@
                        useJWD: true // 仅使用经纬度
                    }
                    that.$store.dispatch('setMobileWindows', d)
                } else if (that.urlParameterData.methods == 'arc') {
                    const objInit = {
                        name: that.urlParameterData.mechanismname,
                        lntLat: [that.urlParameterData.jd, that.urlParameterData.wd],
                        alt: that.urlParameterData.gd,
                        heading: that.urlParameterData.heading,
                        pitch: that.urlParameterData.pitch,
                        roll: that.urlParameterData.roll,
                        bgImg: that.urlParameterData.tpurl,
                        QRImg: that.urlParameterData.codeurl,
                        websiteUrl: that.urlParameterData.websiteurl,
                        telePhone: that.urlParameterData.telephone,
                        address: that.urlParameterData.address,
                        introduce: that.urlParameterData.introduce,
                        video: that.urlParameterData.videourl,
                        panoramaurl: that.urlParameterData.panoramaurl // 全景
                    }
                    const dataInitialization = {
                        position: {},
                        lntLat: objInit.lntLat,
                        query: { ...objInit },
                        useJWD: true, // 仅使用经纬度
                        from: 'PopupOurOnce'
                    }
                    that.popupsDom = that.$store.dispatch('setMobileWindows', dataInitialization)
                }
            }
        }, 0)