/**
|
* 加载业务数据图层
|
*/
|
import { logicMapper } from '@src/conf/Constants'
|
|
class BusiLayerService {
|
constructor (config) {
|
this.L = window.L
|
this.map = window.map
|
this.config = config
|
}
|
|
init (layer) {
|
// 引入 关联的js,在constant.js中根据config配置的id得到处理js
|
const id = this.config.code
|
console.log(id)
|
const file = logicMapper[id]
|
if (!file) {
|
console.log('找不到逻辑处理js!!!' + id)
|
} else {
|
var BusiLayer = require('../logic/' + file)
|
var busiLayer = new BusiLayer()
|
busiLayer.init(layer, this.L)
|
if (busiLayer.bindTooltip) {
|
// 全局tips位置
|
layer.bindTooltip(busiLayer.bindTooltip, { direction: 'top', offset: [0, -15], sticky: false })
|
}
|
// 调用click事件
|
if (busiLayer.clickListener) {
|
layer.on('click', busiLayer.clickListener)
|
}
|
layer.addTo(this.map)
|
}
|
}
|
}
|
|
export default BusiLayerService
|