| | |
| | | import { getToken } from "@/utils/auth"; |
| | | //配置文件地址 |
| | | import config from "./config"; |
| | | |
| | | import store from "@/store"; |
| | | const server = { |
| | | layerList: [], |
| | | addTreeData(treeNode) { |
| | |
| | | //加载GeoServer-WMS服务 |
| | | setAddGeoWmsLayer(res) { |
| | | var url = this.getLayrUrl(res); |
| | | var that = this |
| | | var getFeatureInfoFormat = new SmartEarth.Cesium.GetFeatureInfoFormat("html", null, function (html) { |
| | | that.getFeatureInfo(html) |
| | | }); |
| | | let layer = new SmartEarth.Cesium.WebMapServiceImageryProvider({ |
| | | url: url, |
| | | layers: res.tab, |
| | | getFeatureInfoParameters: { info_format: 'text/html' }, |
| | | enablePickFeatures: true, |
| | | getFeatureInfoFormats: [getFeatureInfoFormat], |
| | | parameters: { |
| | | transparent: true, |
| | | format: "image/png", |
| | |
| | | let img_layer = window.Viewer.imageryLayers.addImageryProvider(layer); |
| | | this.layerList.push({ id: res.id, layerData: img_layer, type: "wmts" }); |
| | | }, |
| | | getFeatureInfo(html) { |
| | | store.state.details.showDetails = false; |
| | | var start = html.indexOf("<caption class=\"featureInfo\">") + "<caption class=\"featureInfo\">".length; |
| | | var end = html.indexOf("</caption>"); |
| | | var tab = html.substr(start, end - start); |
| | | var std = html.substr(html.indexOf('<th>'), html.lastIndexOf('</th>') - html.indexOf('<th>') + 5).replaceAll(' ', '').replaceAll('\n', '').split('</th>') |
| | | var gindex = null; |
| | | for (var i = 0; i < std.length; i++) { |
| | | if (std[i].indexOf('gid') > -1) { |
| | | gindex = i; |
| | | break; |
| | | } |
| | | } |
| | | if (!gindex) return |
| | | var str = html.substr(html.indexOf('<td>'), html.lastIndexOf('</td>') - html.indexOf('<td>') + 5).replaceAll(' ', '').replaceAll('\n', '').split('</td>') |
| | | var gid = parseInt(str[gindex].replaceAll( |
| | | '<td>', '' |
| | | )) |
| | | if (gid && tab) { |
| | | |
| | | store.state.details = { |
| | | gid: gid, |
| | | tab: tab, |
| | | showDetails: true |
| | | } |
| | | } |
| | | |
| | | }, |
| | | }; |
| | | export default server; |