| | |
| | | import clone from '../../../utils/utils' |
| | | |
| | | /** |
| | | * 组装wms加载所需的layers以及filters参数 |
| | | */ |
| | | class WmsLayerList { |
| | | constructor () { |
| | | // [{图层名称:[{typeName:xxx,filter:yyy}]}] |
| | |
| | | const typeName = config.typeName |
| | | const layerGroup = config.layerGroup || typeName |
| | | const filter = config.filter |
| | | const index = config.index || 9 |
| | | const index = config.index |
| | | if (layerGroup) { |
| | | this.addLayer(layerGroup, typeName, filter, index) |
| | | } |
| | |
| | | |
| | | addLayer (layerGroup, typeName, filter, index) { |
| | | const layer = this._getLayer(layerGroup) |
| | | |
| | | if (layer) { |
| | | const offset = this.indexOf(typeName, filter) |
| | | if (offset < 0) { |
| | |
| | | } else { |
| | | const layerConfig = {} |
| | | layerConfig[layerGroup] = [{ typeName: typeName, filter: filter || 'INCLUDE' }] |
| | | if (index) { |
| | | this.layers[index] = layerConfig |
| | | } else { |
| | | this.layers.push(layerConfig) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | const layers = this.layers |
| | | for (let i = 0; i < layers.length; i++) { |
| | | const lay = layers[i] |
| | | if (lay[layer]) { |
| | | if (lay && lay[layer]) { |
| | | return lay |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | if (filters.length > 0) { |
| | | cqlFilters.push(filters.join(' OR ')) |
| | | } |
| | | } |
| | | return cqlFilters.join(';') |
| | | } |
| | | |
| | |
| | | export default { |
| | | name: 'LcServiceLayer', |
| | | components: { LcServiceLayerFilter }, |
| | | data () { |
| | | return { |
| | | changeList: [] |
| | | } |
| | | }, |
| | | computed: { |
| | | serviceLayers () { |
| | | return this.$store.state.map.serviceLayers.LayerSewersLine |
| | |
| | | swAllLayers (item) { |
| | | // eslint-disable-next-line no-debugger |
| | | item.checked = !item.checked |
| | | this.toggleLayer(item) |
| | | // this.toggleLayer(item) |
| | | if (item.layers && item.layers.length > 0) { |
| | | this.swLayers(item.layers, item.checked) |
| | | if (item.checked) { |
| | | window.layerFactory.showAll(this.changeList) |
| | | } else { |
| | | window.layerFactory.hideAll(this.changeList) |
| | | } |
| | | this.changeList = [] |
| | | } else { |
| | | this.toggleLayer(item) |
| | | } |
| | | this.serviceLayers.forEach(function (item1, index1) { |
| | | if (item1.layers) { |
| | | item1.istrue = 0 |
| | |
| | | }) |
| | | // console.log(this.serviceLayers) |
| | | }, |
| | | swLayers (layers, checked) { |
| | | if (layers) { |
| | | for (let i = 0, len = layers.length; i < len; ++i) { |
| | | var layer = layers[i] |
| | | layer.checked = checked |
| | | this.toggleLayer(layer) |
| | | if (layer.layers) { |
| | | this.swLayers(layer.layers, checked) |
| | | swLayers (configs, checked) { |
| | | if (configs) { |
| | | for (let i = 0, len = configs.length; i < len; ++i) { |
| | | var config = configs[i] |
| | | config.checked = checked |
| | | this.changeList.push(config) |
| | | if (config.layers) { |
| | | this.swLayers(config.layers, checked) |
| | | } |
| | | } |
| | | } |
| | |
| | | return { |
| | | visible: {}, |
| | | layers: [], |
| | | changeList: [], |
| | | filterConfig: [] // 附属要素 |
| | | } |
| | | }, |
| | |
| | | // eslint-disable-next-line no-debugger |
| | | item.checked = !item.checked |
| | | this.toggleLayer(item) |
| | | if (item.layers && item.layers.length > 0) { |
| | | this.swLayers(item.layers, item.checked) |
| | | }, |
| | | swLayers (layers, checked) { |
| | | if (layers) { |
| | | for (let i = 0, len = layers.length; i < len; ++i) { |
| | | var layer = layers[i] |
| | | layer.checked = checked |
| | | this.toggleLayer(layer) |
| | | if (layer.layers) { |
| | | this.swLayers(layer.layers, checked) |
| | | if (item.checked) { |
| | | window.layerFactory.showAll(this.changeList) |
| | | } else { |
| | | window.layerFactory.hideAll(this.changeList) |
| | | } |
| | | this.changeList = [] |
| | | } else { |
| | | this.toggleLayer(item) |
| | | } |
| | | }, |
| | | swLayers (configs, checked) { |
| | | if (configs) { |
| | | for (let i = 0, len = configs.length; i < len; ++i) { |
| | | const config = configs[i] |
| | | const layers = config.layers |
| | | this.changeList.push(config) |
| | | if (layers) { |
| | | this.swLayers(config, checked) |
| | | } |
| | | config.checked = checked |
| | | } |
| | | } |
| | | }, |
| | |
| | | return layer |
| | | } |
| | | |
| | | showAll (configs) { |
| | | if (Array.isArray(configs)) { |
| | | for (let i = 0; i < configs.length; i++) { |
| | | const config = configs[i] |
| | | this.show(config) |
| | | } |
| | | this.wmsLayerService && this.wmsLayerService.addAll(configs) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 如果 存在已经加载了的对象,就直接加到map |
| | | * 如果 不存在则 调用 addLayer 及 逻辑类的init 进行初始化操作 |
| | |
| | | this.wmsLayerService && this.wmsLayerService.add(config) |
| | | } |
| | | |
| | | hideAll (configs) { |
| | | if (Array.isArray(configs)) { |
| | | for (let i = 0; i < configs.length; i++) { |
| | | this.hide(configs[i]) |
| | | } |
| | | this.wmsLayerService && this.wmsLayerService.removeAll(configs) |
| | | } |
| | | } |
| | | |
| | | hide (config) { |
| | | const code = config.code |
| | | const layer = this.layers[code] |
| | |
| | | init () { |
| | | } |
| | | |
| | | addAll (configs) { |
| | | for (let i = 0; i < configs.length; i++) { |
| | | const config = configs[i] |
| | | const layers = config.layers |
| | | if (layers) { |
| | | this.addAll(layers) |
| | | } |
| | | this.wmsLayerList.addConfig(config) |
| | | } |
| | | this.reload() |
| | | } |
| | | |
| | | add (config) { |
| | | this.wmsLayerList.addConfig(config) |
| | | this.reload() |
| | | } |
| | | |
| | | removeAll (configs) { |
| | | for (let i = 0; i < configs.length; i++) { |
| | | const config = configs[i] |
| | | const layers = config.layers |
| | | if (layers) { |
| | | this.removeAll(layers) |
| | | } |
| | | this.wmsLayerList.remove(config.typeName, config.filter) |
| | | } |
| | | this.reload() |
| | | } |
| | | |
| | | remove (config) { |
| | | this.wmsLayerList.remove(config.typeName, config.filter) |
| | | this.reload() |
| | | } |
| | | |
| | | reload () { |
| | | const layers = this.wmsLayerList.getLayers() || '' |
| | | const filter = this.wmsLayerList.getFilters() || '' |
| | | const params = {} |
| | | params.cql_filter = filter |
| | | params.layers = layers |
| | | this.wmsLayer.setParams(params) |
| | | } |
| | | |
| | | remove (config) { |
| | | this.wmsLayerList.remove(config.typeName, config.filter) |
| | | const layers = this.wmsLayerList.getLayers() || '' |
| | | const filter = this.wmsLayerList.getFilters() || '' |
| | | const params = { layers: layers } |
| | | params.cql_filter = filter |
| | | this.wmsLayer.setParams(params) |
| | | this.wmsLayer.setParams(params, false) |
| | | } |
| | | |
| | | load () { |