| | |
| | | import WfsLayerService from './WfsLayerService' |
| | | import BusiLayerService from './BusiLayerService' |
| | | import WmsLayerService from './WmsLayerService' |
| | | |
| | | class LayerFactory { |
| | | constructor (options) { |
| | | this.L = options.L |
| | | this.map = window.map |
| | | this.layers = {} |
| | | } |
| | | |
| | | createLayerGroup () { |
| | | return this.L.layerGroup().addTo(this.map) |
| | | } |
| | | |
| | | init () { |
| | |
| | | var wfs = childConfig.wfs |
| | | var wms = childConfig.wms |
| | | var url = childConfig.url |
| | | // 判断是否已经加载过,加载过就 忽略掉 |
| | | const layer = this.layers[code] |
| | | // 判断是否已经加载过,加载过就 直接得到对象调用 显示函数 |
| | | var layer = this.layers[code] |
| | | if (!layer) { |
| | | const newLayer = this.createLayerGroup() |
| | | this.layers[code] = newLayer |
| | | layer = this.L.featureGroup({}).addTo(this.map) |
| | | // 2. 判断类型 |
| | | if (wfs) { |
| | | // 3. 实例化具体service |
| | | // var busiLayerService = new BusiLayerService() |
| | | // busiLayerService.init() |
| | | var wfsLayerService = new WfsLayerService(childConfig) |
| | | wfsLayerService.init(newLayer) |
| | | wfsLayerService.init(layer) |
| | | } |
| | | if (wms) { |
| | | var wmsLayerService = new WmsLayerService(childConfig) |
| | | wmsLayerService.init(newLayer) |
| | | wmsLayerService.init(layer) |
| | | } |
| | | // 请求业务数据接口 |
| | | if (url) { |
| | | var busiLayerService = new BusiLayerService(childConfig) |
| | | busiLayerService.init(newLayer) |
| | | busiLayerService.init(layer) |
| | | } |
| | | layer ? (this.layers[code] = layer) : console.log('LayerFactory:newLayer is null,please check !!!') |
| | | } else { |
| | | this.show(code) |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 设置index,线在最下面,点在上面 |
| | | * @param layerGroup 图层组 |
| | | */ |
| | | * 设置index,线在最下面,点在上面 |
| | | * @param layerGroup 图层组 |
| | | */ |
| | | setZIndex (layerGroup) { |
| | | var layers = layerGroup.getLayers() |
| | | if (layers.length > 0) { |