From ba3db6e901ac35e92a8c09f6c9aab4e18acdd7b4 Mon Sep 17 00:00:00 2001
From: 徐旺旺 <11530253@qq.com>
Date: 星期二, 12 一月 2021 12:28:12 +0800
Subject: [PATCH] 调整顺序
---
src/components/helpers/VectorLayerHelper.js | 72 +++++++++++++++---------------------
1 files changed, 30 insertions(+), 42 deletions(-)
diff --git a/src/components/helpers/VectorLayerHelper.js b/src/components/helpers/VectorLayerHelper.js
index 04abe59..38b9102 100644
--- a/src/components/helpers/VectorLayerHelper.js
+++ b/src/components/helpers/VectorLayerHelper.js
@@ -1,68 +1,56 @@
/**
* 涓氬姟鐩稿叧鐭㈤噺鍥剧鐞嗗姪鎵嬶紝璐熻矗涓氬姟鐩稿叧鐭㈤噺鍥惧垱寤哄強寮�鍏�
*/
-function VectorLayerHelper(options) {
- this.map = options.map
- this.L = options.L
- this.vectorLayerMap = {}
- this.vectorLayerList = []
- this.vueRefMap = {}
- this.functionMap = {}
- /**
+function VectorLayerHelper (options) {
+ this.map = options.map
+ this.L = options.L
+ this.vectorLayerMap = new Map()
+ this.vectorLayerList = []
+ 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.initVectorLayers = (vueState) => {
+ this.vectorLayerGroup = options.L.layerGroup().addTo(options.map)
+ this.vueState = vueState
+ }
-
-
- this.setVueRef = (vueName, ref) => {
- this.vueRefMap[vueName] = ref
- }
-
- /**
+ /**
* 鑾峰彇鎵�鏈夌殑鍥惧眰鍒楄〃
* @returns {null} 缁撴瀯锛歔{鍚嶇О, 鍥惧眰寮曠敤}]
*/
- this.getVectorLayerList = () => {
- return this.vectorLayerList
- }
+ this.getVectorLayerList = () => {
+ return this.vectorLayerList
+ }
- /**
+ /**
* 閫氳繃鍚嶇О鑾峰彇鍥惧眰瀵硅薄
* @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) => {
+ const layer = this.vectorLayerMap.get(code)
+ this.map.addLayer(layer)
+ }
- /**
+ /**
* 闅愯棌鏌愪釜鍥惧眰
* @param name 鍥惧眰鍚嶇О
*/
- this.hideVectorLayer = (name, vuexStat) => {
- console.log(this.map, vuexStat)
- }
+ this.hideVectorLayer = (code) => {
+ const layer = this.vectorLayerMap.get(code)
+ this.map.removeLayer(layer)
+ }
}
export default VectorLayerHelper
--
Gitblit v1.8.0