| | |
| | | //配置文件地址 |
| | | // import config from "../../../../public/config/config"; |
| | | import store from "@/store"; |
| | | import { nextTick } from "vue"; |
| | | const server = { |
| | | layerList: [], |
| | | graticules: null, |
| | | alpha: null,//透明度 |
| | | |
| | | geoLayer: [], |
| | | geoUrl: null, |
| | | wmsLayerId: null, |
| | | addTreeData(treeNode) { |
| | | if (!treeNode.checked) { |
| | | this.delLayer(treeNode.id); |
| | |
| | | } |
| | | }, |
| | | //加载GeoServer-WMS服务 |
| | | setAddGeoWmsLayer(res) { |
| | | this.delLayer(res.id) |
| | | setAddGeoWmsLayer(res, alpha) { |
| | | // |
| | | var url = res.url; |
| | | var that = this; |
| | | |
| | | this.delLayer(res.id) |
| | | var getFeatureInfoFormat = new SmartEarth.Cesium.GetFeatureInfoFormat( |
| | | "html", |
| | | null, |
| | |
| | | tileWidth: 512, |
| | | tileHeight: 512, |
| | | }); |
| | | layer.name = `Wms_Layer${res.id}`; |
| | | |
| | | let img_layer = window.Viewer.imageryLayers.addImageryProvider(layer); |
| | | img_layer.name = `Wms_Layer${res.id}`; |
| | | img_layer.id = res.id |
| | | img_layer.alpha = this.alpha; |
| | | img_layer.alpha = alpha ? alpha : 1; |
| | | this.layerList.push({ id: res.id, layerData: img_layer, type: "wmts" }); |
| | | }, |
| | | addGeoServerMmsLayers(layer, url) { |
| | | this.geoLayer = layer; |
| | | this.geoUrl = url; |
| | | var that = this; |
| | | var getFeatureInfoFormat = new SmartEarth.Cesium.GetFeatureInfoFormat( |
| | | "html", |
| | | null, |
| | | function (html) { |
| | | |
| | | that.getFeatureInfo(html); |
| | | } |
| | | ); |
| | |
| | | } else { |
| | | url = url; |
| | | } |
| | | |
| | | if (!this.wmsLayerId) { |
| | | this.wmsLayerId = new Date(); |
| | | } |
| | | let wmslayer = new SmartEarth.Cesium.WebMapServiceImageryProvider({ |
| | | url: url, |
| | | id: this.wmsLayerId, |
| | | layers: layer.toString(), |
| | | getFeatureInfoParameters: { info_format: "text/html" }, |
| | | enablePickFeatures: true, |
| | |
| | | tileWidth: 512, |
| | | tileHeight: 512, |
| | | }); |
| | | wmslayer.name = `Wms_Layer_geo`; |
| | | |
| | | let img_layer = window.Viewer.imageryLayers.addImageryProvider(wmslayer); |
| | | this.layerList.push({ id: res.id, layerData: img_layer, type: "wmts" }); |
| | | img_layer.id = this.wmsLayerId; |
| | | this.layerList.push({ id: this.wmsLayerId, layerData: img_layer, type: "wmts" }); |
| | | }, |
| | | getGeoLayerChangeAlpha(res) { |
| | | var std = []; |
| | | for (var i in this.geoLayer) { |
| | | if (this.geoLayer[i] != res.tab) { |
| | | std.push(this.geoLayer[i]) |
| | | } |
| | | } |
| | | this.geoLayer = []; |
| | | this.geoLayer = std; |
| | | var imageLayers = window.Viewer.imageryLayers._layers; |
| | | for (var i in imageLayers) { |
| | | if (imageLayers[i].id == this.wmsLayerId) { |
| | | |
| | | window.Viewer.imageryLayers.remove(imageLayers[i]) |
| | | } |
| | | } |
| | | for (var i in this.layerList) { |
| | | if (this.layerList[i].id == this.wmsLayerId) { |
| | | this.layerList.splice(i, 1) |
| | | } |
| | | } |
| | | if (this.geoLayer.length > 0) { |
| | | this.addGeoServerMmsLayers(this.geoLayer, this.geoUrl) |
| | | } |
| | | this.setAddGeoWmsLayer(res); |
| | | for (var i in this.layerList) { |
| | | if (this.layerList[i].id == res.id) { |
| | | return { |
| | | id: i, |
| | | layer: this.layerList[i] |
| | | }; |
| | | break; |
| | | } |
| | | } |
| | | }, |
| | | getFeatureInfo(html) { |
| | | |
| | | var start = |
| | | html.indexOf('<caption class="featureInfo">') + |
| | | '<caption class="featureInfo">'.length; |