From 5b3b9895f857d217ef42f96b7ad1aa68103236c4 Mon Sep 17 00:00:00 2001 From: Surpriseplus <845948745@qq.com> Date: 星期日, 26 二月 2023 14:40:49 +0800 Subject: [PATCH] 图层管理默认不展开 --- src/views/Tools/LayerTree.vue | 1 src/views/Synthesis/LeftMenu.vue | 216 +++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 181 insertions(+), 36 deletions(-) diff --git a/src/views/Synthesis/LeftMenu.vue b/src/views/Synthesis/LeftMenu.vue index 214d6ed..4dc39c7 100644 --- a/src/views/Synthesis/LeftMenu.vue +++ b/src/views/Synthesis/LeftMenu.vue @@ -6,13 +6,21 @@ v-for="(item, index) in setListTwoMenu" :class="{ lefMenuDivActive: showTwoMenuFlag == item.id }" > - <div class="menuTwoImage" :class="item.css"></div> + <div + class="menuTwoImage" + :class="item.css" + ></div> <div>{{ $t(item.label) }}</div> </div> <mapinfo ref="mapinfo" /> <maplayer ref="maplayer" /> <queryinfo ref="queryinfo" /> - <input type="file" accept=".kml" class="file" style="display: none" /> + <input + type="file" + accept=".kml" + class="file" + style="display: none" + /> <input :accept="'.shp, .shx, .dbf, .prj'" style="display: none" @@ -33,6 +41,12 @@ import queryinfo from "../Tools/queryinfo.vue"; import $ from "jquery"; import { getToken } from "@/utils/auth"; +import ImageWMS from "ol/source/ImageWMS"; +import Image from "ol/layer/Image"; +import GeoJSON from "ol/format/GeoJSON.js"; +import { Vector as VectorSource } from "ol/source"; +import { Vector as VectorLayer } from "ol/layer"; +import { perms_selectLayers } from '../../api/api.js' import { OverviewMap, defaults as defaultControls, @@ -470,28 +484,28 @@ sgworld.Creator.createSimpleGraphic( "point", {}, - function (entity) {} + function (entity) { } ); break; case "h2": sgworld.Creator.createSimpleGraphic( "polyline", {}, - function (entity) {} + function (entity) { } ); break; case "h3": sgworld.Creator.createSimpleGraphic( "rectangle", {}, - function (entity) {} + function (entity) { } ); break; case "h4": sgworld.Creator.createSimpleGraphic( "polygon", {}, - function (entity) {} + function (entity) { } ); break; case "h5": @@ -518,7 +532,7 @@ sgworld.Creator.createSimpleGraphic( "label", {}, - function (entity) {} + function (entity) { } ); break; } @@ -703,7 +717,7 @@ document.body.removeChild(a); // 閲婃斁 } }, - error: function (e) {}, + error: function (e) { }, }); }, handleOpenShp() { @@ -910,18 +924,18 @@ url, name, "height=" + - iHeight + - ",,innerHeight=" + - iHeight + - ",width=" + - iWidth + - ",innerWidth=" + - iWidth + - ",top=" + - iTop + - ",left=" + - iLeft + - ",toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no" + iHeight + + ",,innerHeight=" + + iHeight + + ",width=" + + iWidth + + ",innerWidth=" + + iWidth + + ",top=" + + iTop + + ",left=" + + iLeft + + ",toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no" ); }, @@ -1009,9 +1023,8 @@ "auto", (data) => { if (volumetricMeasurementTool.popupData) { - volumetricMeasurementTool.popupData.value = `濉柟锛�${ - data.volume.fill.toFixed(4) + data.unit.fill - }<br>鎸栨柟锛�${data.volume.dig.toFixed(4) + data.unit.dig}`; + volumetricMeasurementTool.popupData.value = `濉柟锛�${data.volume.fill.toFixed(4) + data.unit.fill + }<br>鎸栨柟锛�${data.volume.dig.toFixed(4) + data.unit.dig}`; } else { data.id = window.sgworld.Core.getuid(); this.measureData.set(data.id, volumetricMeasurementTool); @@ -1070,9 +1083,8 @@ }); break; case "浣撶Н鏂归噺": - info = `濉柟锛�${ - data.volume.fill.toFixed(4) + data.unit.fill - }<br>鎸栨柟锛�${data.volume.dig.toFixed(4) + data.unit.dig}`; + info = `濉柟锛�${data.volume.fill.toFixed(4) + data.unit.fill + }<br>鎸栨柟锛�${data.volume.dig.toFixed(4) + data.unit.dig}`; break; } return ( @@ -1157,20 +1169,20 @@ PDelevationTool.render(); break; case "d3": //璺緞鍒嗘瀽 - + this.isRouter = !this.isRouter; let value; if (this.isRouter) { value = { name: "Analysis", id: 3, - show:true + show: true }; } else { value = { name: "Analysis", id: 3, - show:false + show: false }; } this.$bus.$emit("mapChangeBox", value); @@ -1210,9 +1222,8 @@ "auto", (data) => { if (TFvolumetricMeasurementTool.popupData) { - TFvolumetricMeasurementTool.popupData.value = `濉柟锛�${ - data.volume.fill.toFixed(4) + data.unit.fill - }<br>鎸栨柟锛�${data.volume.dig.toFixed(4) + data.unit.dig}`; + TFvolumetricMeasurementTool.popupData.value = `濉柟锛�${data.volume.fill.toFixed(4) + data.unit.fill + }<br>鎸栨柟锛�${data.volume.dig.toFixed(4) + data.unit.dig}`; } else { data.id = sgworld.Core.getuid(); this.measureData.set(data.id, TFvolumetricMeasurementTool); @@ -1319,7 +1330,7 @@ window.Excavation = sgworld.Analysis.TerrainExcavation( 10, {}, - function () {} + function () { } ); } break; @@ -1422,7 +1433,7 @@ 2, 2, method, - (value) => {} + (value) => { } ); }, addterrainSectionAnalysis() { @@ -1461,7 +1472,7 @@ setWander(res) { debugger; switch (res) { - + case "c1": if (window.PointMY != null) { window.PointMY.drawHandler && window.PointMY.drawHandler.destroy(); @@ -1599,6 +1610,136 @@ menuChange(res) { this.setListTwoMenu = this.setListTwoMenuAll[res]; }, + async layersStart() { + const data = await perms_selectLayers(); + if (data.code != 200) { + return this.$message.error("鍥惧眰鍒楄〃鏌ヨ澶辫触"); + } + var std = data.result; + var that = this; + var checkKey = []; + var val = std.filter((str) => { + if (str.type == 1) { + return str; + } + if (str.url != null && str.type == 2) { + if (str.isShow == 1) { + checkKey.push(str.id); + that.setAddLayers(str); + } + return str; + } + }); + + var res = this.setTreeData(val); + + for (var i in res) { + res[i].children = res[i].children.filter((val) => { + if (val.children != null) { + return val; + } + }); + } + this.$store.state.treeData = res; + // this.$refs.tree.setCheckedKeys(checkKey); + this.$store.state.checkedKeys = checkKey + }, + setAddLayers(res) { + if (res.serveType == "WMS") { + var resource = geoServerURl; + if (res.resource != null && res.resource != undefined) { + resource = res.resource; + } + var imageryLayers = window.Viewer.scene.imageryLayers; + let layerWMS = new Cesium.WebMapServiceImageryProvider({ + url: resource, + layers: res.url, + parameters: { + transparent: true, + format: "image/png", + srs: "EPSG:4490", + styles: "", + }, + tileWidth: 512, + tileHeight: 512, + }); + layerWMS.name = res.cnName; + //閫忔槑搴� + var tdtAnnoLayer = imageryLayers.addImageryProvider(layerWMS); + if (res.opacity) { + tdtAnnoLayer.alpha = parseInt(res.opacity) / 100; + } + var layer2 = new Image({ + name: res.cnName, + source: new ImageWMS({ + crossOrigin: "anonymous", + url: resource, + params: { + FORMAT: "image/png", + VERSION: "1.1.1", + LAYERS: res.url, + }, + }), + }); + if (res.opacity) { + layer2.setOpacity(parseInt(res.opacity) / 100); + } + window.map.addLayer(layer2); + } else if (res.serveType == "WFS") { + var url = + res.resource + + "?service=WFS&version=1.0.0&request=GetFeature&typeName=" + + res.url + + "&outputFormat=application%2Fjson"; + $.ajax({ + url: url, + cache: false, + async: true, + success: function (data) { + var datasource = Cesium.GeoJsonDataSource.load(data, { + stroke: Cesium.Color.YELLOW, + fill: Cesium.Color.YELLOW.withAlpha(0.1), + alpha: 0.1, + strokeWidth: 8, + clampToGround: true, //鏄惁璐村湴 + }); + datasource.then((data) => { + data.name = res.cnName; + window.Viewer.dataSources.add(data); + }); + }, + error: function (data) { + console.log("error"); + }, + }); + + var vectorLayer = new VectorLayer({ + name: res.cnName, + source: new VectorSource({ + url: url, + format: new GeoJSON(), + }), + }); + window.map.addLayer(vectorLayer); + } else if (res.serveType == "Tileset") { + debugger + var tileset = Viewer.scene.primitives.add( + new Cesium.Cesium3DTileset({ + name: res.cnName, + url: modelUrl + "/" + res.url, //192.168.20.106,to4 + maximumScreenSpaceError: 64, // 鏈�澶у睆骞曠┖闂撮敊璇細16 + maximumMemoryUsage: 768, // 鏈�澶у唴瀛橈細512 + dynamicScreenSpaceError: true, // 鍑忓皯绂荤浉鏈鸿緝杩滅殑灞忓箷绌洪棿閿欒锛歠alse + skipLevelOfDetail: true, // 鍦ㄩ亶鍘嗘椂鍊欒烦杩囪鎯咃細false + }) + ); + + tileset.readyPromise.then(function (tileset) { + tileset.id = res.cnName; + Viewer.flyTo(tileset); + }); + } + }, }, mounted() { this.measureData = new Map(); @@ -1607,6 +1748,7 @@ polyline: Cesium.Color.fromCssColorString("#ffff00").withAlpha(0.6), polygon: Cesium.Color.fromCssColorString("#ffff00").withAlpha(0.6), }; + this.$bus.$on("setChangeTwoMenu", (res) => { if (res == 8) { this.setLayerScene(); @@ -1619,7 +1761,9 @@ this.$store.state.layerMnage = false; this.$store.state.treeData = null; this.$store.state.checkedKeys = []; - this.setCoverage("a1"); + // this.setCoverage("a1"); + this.layersStart() + }, }; </script> diff --git a/src/views/Tools/LayerTree.vue b/src/views/Tools/LayerTree.vue index 0a3a1b2..eadd648 100644 --- a/src/views/Tools/LayerTree.vue +++ b/src/views/Tools/LayerTree.vue @@ -734,6 +734,7 @@ }, }, mounted() { + this.$bus.$on("treeDataCopy", (res) => { this.$store.state.treeData = this.treeData; this.$store.state.checkedKeys = this.$refs.tree.getCheckedKeys(); -- Gitblit v1.9.3