| | |
| | | import AjaxUtils from '../../../utils/AjaxUtils' |
| | | import { PIPELINE_WMS } from '../../../conf/Constants' |
| | | import Popup from '@views/popup/Popup' |
| | | import List from '../../../utils/List' |
| | | |
| | | /** |
| | | * todo 得考虑一个图层配置了多个 wmsLayers的情况 |
| | |
| | | // 存放getfeatureinfo的图层组 |
| | | this.featureGroup = this.L.featureGroup({}).addTo(this.map) |
| | | |
| | | this.layers = [] |
| | | this.layers = new List() |
| | | for (var i = 0; i < layersConfig.length; i++) { |
| | | const config = layersConfig[i] |
| | | for (var k in config) { |
| | | if (k === 'wmsLayers') { |
| | | this.layers.push(config[k]) |
| | | } |
| | | const typeName = config.typeName |
| | | if (typeName) { |
| | | this.layers.add(config.index, typeName) |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | add (config) { |
| | | const wmsLayers = config.wmsLayers |
| | | if (wmsLayers) { |
| | | if (this.layers.indexOf(wmsLayers) < 0) { |
| | | this.layers.push(config.wmsLayers) |
| | | const typeName = config.typeName |
| | | if (typeName) { |
| | | if (!this.layers.contains(typeName)) { |
| | | this.layers.add(config.index, typeName) |
| | | this.wmsLayer.setParams({ layers: this.layers.join(',') }) |
| | | } |
| | | } |
| | | } |
| | | |
| | | remove (config) { |
| | | const wmsLayers = config.wmsLayers |
| | | for (var i = 0; i < this.layers.length; i++) { |
| | | const layerName = this.layers[i] |
| | | if (wmsLayers === layerName) { |
| | | this.layers.splice(i, 1) |
| | | } |
| | | } |
| | | const typeName = config.typeName |
| | | this.layers.remove(typeName) |
| | | this.wmsLayer.setParams({ layers: this.layers.join(',') }) |
| | | } |
| | | |
| | |
| | | this.wmsLayer = this.L.tileLayer.wms(PIPELINE_WMS, { |
| | | format: 'image/png', // 返回的数据格式 |
| | | transparent: true, |
| | | layers: layers.join(',') |
| | | layers: this.layers.join(',') |
| | | }).addTo(this.map) |
| | | } |
| | | |
| | | clickListener () { |
| | | window.map.on('click', (e) => { |
| | | console.log(e) |
| | | this.featureGroup.clearLayers() |
| | | var point = this.map.latLngToContainerPoint(e.latlng, this.map.getZoom()) |
| | | var size = this.map.getSize() |
| | | // const bbox = this.L.latLngBounds(this.L.latLng(e.latlng.lng, e.latlng.lat)).toBBoxString() |
| | | |
| | | if (this.layers && this.layers.length > 0) { |
| | | if (this.layers.length() > 0) { |
| | | const params = Object.assign({ |
| | | LAYERS: this.layers.join(','), |
| | | QUERY_LAYERS: this.layers.join(','), |
| | |
| | | AjaxUtils.get4JsonDataByUrl(PIPELINE_WMS, params, (res) => { |
| | | const features = res.data.features |
| | | /** |
| | | * { |
| | | * title: 'New Tab', |
| | | * name: newTabName, |
| | | * content: 'New Tab content' |
| | | * } |
| | | * @type {*[]} |
| | | */ |
| | | * { |
| | | * title: 'New Tab', |
| | | * name: newTabName, |
| | | * content: 'New Tab content' |
| | | * } |
| | | * @type {*[]} |
| | | */ |
| | | const popupDatas = [] |
| | | if (features) { |
| | | for (var i = 0; i < features.length; i++) { |
| | |
| | | datas: popupDatas |
| | | } |
| | | }, |
| | | title: '' // 标题 |
| | | title: '', // 标题 |
| | | left: e.originalEvent.clientX, |
| | | top: e.originalEvent.clientY |
| | | }) |
| | | } |
| | | // this.popupComp.setDatas(popupDatas) |