From 1ba44459ed390fbcb4b05dea06923e4df99d3acc Mon Sep 17 00:00:00 2001
From: wangrui <zephyrs0894@163.com>
Date: 星期三, 23 十二月 2020 15:06:11 +0800
Subject: [PATCH] basemap图层控制ui

---
 src/components/helpers/VectorLayerHelper.js |   40 ++++++++++++++--------------------------
 1 files changed, 14 insertions(+), 26 deletions(-)

diff --git a/src/components/helpers/VectorLayerHelper.js b/src/components/helpers/VectorLayerHelper.js
index 04abe59..2ebcbc9 100644
--- a/src/components/helpers/VectorLayerHelper.js
+++ b/src/components/helpers/VectorLayerHelper.js
@@ -4,32 +4,18 @@
 function VectorLayerHelper(options) {
     this.map = options.map
     this.L = options.L
-    this.vectorLayerMap = {}
+    this.vectorLayerMap = new Map()
     this.vectorLayerList = []
-    this.vueRefMap = {}
-    this.functionMap = {}
+    this.vectorLayerGroup = null
+    this.vueState = {} // 鐢ㄦ埛鍥惧眰鏉冮檺
     /**
      * 璇ユ柟娉曡礋璐e悇绉嶅簳鍥惧姞杞藉埌鍦板浘涓�
      * 涓嶅悓椤甸潰鍔犺浇鍥惧眰涓嶅悓鏍规嵁妯″潡绫诲瀷閫夋嫨鍔犺浇涓嶅悓鍥惧眰
      * @param map
-     * @param methodNames 闇�瑕佸姞杞界殑鏂规硶鍚嶇О
      */
-    this.initVectorLayers = (methodNames) => {
-        // todo 鍒涘缓瀹屼互鍚庯紝鎶婂浘灞傞兘鏀惧埌vectorLayerMap瀵硅薄淇濆瓨璧锋潵锛屾柟渚垮叾浠栨帴鍙h皟鐢�
-        // todo 鍦╩apmodules鏂囦欢澶瑰畾涔夌浉鍏冲浘灞傜殑瀹炵幇浠g爜銆�
-        this.loadFunction(methodNames)
-        // todo 浼佷笟鍥惧眰閮藉彲浠ュ悗闈㈠姞鍏ワ紝鐒跺悗缁熶竴鐢盚elper绋嬪簭鏉ョ鐞嗗浘灞傜殑寮�鍏炽��
-        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
     }
 
     /**
@@ -44,24 +30,26 @@
      * 閫氳繃鍚嶇О鑾峰彇鍥惧眰瀵硅薄
      * @param name 鍚嶇О
      */
-    this.getVectorLayer = (name) => {
-        return this.vectorLayerMap[name]
+    this.getVectorLayer = (code) => {
+        return this.vectorLayerMap[code]
     }
 
     /**
      * 鏄剧ず鏌愪釜鍥惧眰
      * @param name  鍥惧眰鍚嶇О
      */
-    this.showVectorLayer = (name, vuexStat) => {
-        console.log(this.map, vuexStat)
+    this.showVectorLayer = (code) => {
+        let layer = this.vectorLayerMap.get(code)
+        this.map.addLayer(layer)
     }
 
     /**
      * 闅愯棌鏌愪釜鍥惧眰
      * @param name  鍥惧眰鍚嶇О
      */
-    this.hideVectorLayer = (name, vuexStat) => {
-        console.log(this.map, vuexStat)
+    this.hideVectorLayer = (code) => {
+        let layer = this.vectorLayerMap.get(code)
+        this.map.removeLayer(layer)
     }
 }
 

--
Gitblit v1.8.0