From 8356b1850885fe03a6bd388500a447dd5c42692c Mon Sep 17 00:00:00 2001
From: YANGDL <114714267@qq.com>
Date: 星期二, 05 一月 2021 10:23:30 +0800
Subject: [PATCH] 优化逻辑
---
src/views/MapTemplate.vue | 34 +++++++++++++++++++---------------
1 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/views/MapTemplate.vue b/src/views/MapTemplate.vue
index cbc4bcc..0356636 100644
--- a/src/views/MapTemplate.vue
+++ b/src/views/MapTemplate.vue
@@ -20,7 +20,7 @@
import LcServiceLayer from '@components/LayerController/modules/LcServiceLayer'
import LcServiceLayerFilter from '@components/LayerController/modules/LcServiceLayerFilter'
import MonitorPanel from '@components/panel/MonitorPanel'
-import { mapMutations, mapState } from 'vuex'
+// import { mapMutations, mapState } from 'vuex'
export default {
name: 'MapTemplate',
@@ -33,10 +33,12 @@
}
},
computed:{
- ...mapState({
- showServiceLayerFilter: state => state.showServiceLayerFilter,
- mapConfig: state => state.mapConfig
- })
+ showServiceLayerFilter(){
+ return this.$store.state.map.showServiceLayerFilter
+ },
+ mapConfig(){
+ return this.$store.state.map.mapConfig
+ }
},
beforeMount(){
this.$nextTick(() => {
@@ -44,12 +46,12 @@
})
},
methods:{
- ...mapMutations({
- setMapObj: 'setMapObj',
- setBasemapHelper: 'setBasemapHelper',
- setServiceLayerHelper: 'setServiceLayerHelper',
- setVectorLayerHelper: 'setVectorLayerHelper'
- }),
+ saveMapStatus(){
+ this.$store.commit('setMapObj', this.mapObj);
+ this.$store.commit('setBasemapHelper', this.basemapHelper);
+ this.$store.commit('setServiceLayerHelper', this.serviceLayerHelper);
+ this.$store.commit('setVectorLayerHelper', this.vectorLayerHelper);
+ },
init() {
const mapcontainer = this.$refs.rootmap
this.mapObj = Sgis.initMap(mapcontainer)
@@ -63,10 +65,12 @@
this.vectorLayerHelper = Sgis.initVectorLayersHelper(this.mapObj.map, this.mapObj.L) // 鍒濆鍖栧姩鎬佽绱犲浘灞傚姪鎵�
this.vectorLayerHelper.initVectorLayers(this.mapConfig)
- this.setMapObj(this.mapObj)
- this.setBasemapHelper(this.basemapHelper)
- this.setServiceLayerHelper(this.serviceLayerHelper)
- this.setVectorLayerHelper(this.vectorLayerHelper)
+
+ this.saveMapStatus()
+ // this.setMapObj(this.mapObj)
+ // this.setBasemapHelper(this.basemapHelper)
+ // this.setServiceLayerHelper(this.serviceLayerHelper)
+ // this.setVectorLayerHelper(this.vectorLayerHelper)
}
}
}
--
Gitblit v1.8.0