| | |
| | | /** |
| | | * 业务相关矢量图管理助手,负责业务相关矢量图创建及开关 |
| | | */ |
| | | function VectorLayerHelper(map, L, env) { |
| | | this.map = map |
| | | this.L = L |
| | | this.vectorLayerMap = {} |
| | | function VectorLayerHelper(options) { |
| | | this.map = options.map |
| | | this.L = options.L |
| | | this.vectorLayerMap = new Map() |
| | | this.vectorLayerList = [] |
| | | this.vueRefMap = {} |
| | | this.functionMap = {} |
| | | this.env = env |
| | | this.vectorLayerGroup = null |
| | | this.vueState = {} // 用户图层权限 |
| | | /** |
| | | * 该方法负责各种底图加载到地图上 |
| | | * 不同页面加载图层不同根据模块类型选择加载不同图层 |
| | | * @param map |
| | | * @param methodNames 需要加载的方法名称 |
| | | */ |
| | | this.initVectorLayers = (methodNames) => { |
| | | // todo 创建完以后,把图层都放到vectorLayerMap对象保存起来,方便其他接口调用 |
| | | // todo 在mapmodules文件夹定义相关图层的实现代码。 |
| | | this.loadFunction(methodNames) |
| | | // todo 企业图层都可以后面加入,然后统一由Helper程序来管理图层的开关。 |
| | | return null |
| | | } |
| | | // 按需加载对应方法创建图层 |
| | | this.loadFunction = (methodNames) => { |
| | | console.log(methodNames) |
| | | } |
| | | |
| | | |
| | | |
| | | this.setVueRef = (vueName, ref) => { |
| | | this.vueRefMap[vueName] = ref |
| | | this.initVectorLayers = (vueState) => { |
| | | this.vectorLayerGroup = options.L.layerGroup().addTo(options.map) |
| | | this.vueState = vueState |
| | | } |
| | | |
| | | /** |
| | |
| | | * 通过名称获取图层对象 |
| | | * @param name 名称 |
| | | */ |
| | | this.getVectorLayer = (name) => { |
| | | return this.vectorLayerMap[name] |
| | | this.getVectorLayer = (code) => { |
| | | return this.vectorLayerMap[code] |
| | | } |
| | | |
| | | /** |
| | | * 显示某个图层 |
| | | * @param name 图层名称 |
| | | */ |
| | | this.showVectorLayer = (name, vuexStat) => { |
| | | console.log(map, vuexStat) |
| | | this.showVectorLayer = (code) => { |
| | | let layer = this.vectorLayerMap.get(code) |
| | | this.map.addLayer(layer) |
| | | } |
| | | |
| | | /** |
| | | * 隐藏某个图层 |
| | | * @param name 图层名称 |
| | | */ |
| | | this.hideVectorLayer = (name, vuexStat) => { |
| | | console.log(map, vuexStat) |
| | | this.hideVectorLayer = (code) => { |
| | | let layer = this.vectorLayerMap.get(code) |
| | | this.map.removeLayer(layer) |
| | | } |
| | | } |
| | | |