From 612ac3de5dc5067b8140272feb378e4f4da8bde4 Mon Sep 17 00:00:00 2001
From: wangrui <zephyrs0894@163.com>
Date: 星期二, 22 十二月 2020 16:53:12 +0800
Subject: [PATCH] 添加服务图层的配置加载。

---
 src/Sgis.js |   95 +++++++++++++++--------------------------------
 1 files changed, 30 insertions(+), 65 deletions(-)

diff --git a/src/Sgis.js b/src/Sgis.js
index 378fcba..20e2d1a 100644
--- a/src/Sgis.js
+++ b/src/Sgis.js
@@ -1,112 +1,77 @@
 import * as L from 'leaflet'
 import BasemapHelper from '@components/helpers/BasemapHelper'
 import VectorLayerHelper from '@components/helpers/VectorLayerHelper'
+import ServiceLayerHelper from '@components/helpers/ServiceLayerHelper'
 
-// import Editable from '@components/plugin/Editable'
-// import PathDrag from '@components/plugin/PathDrag'
-// import CanvasIcon from '@components/plugin/CanvasMarkers'
-// import MagicMarker from '@components/plugin/MagicMarker'
+import Editable from '@components/plugin/Editable'
+import PathDrag from '@components/plugin/PathDrag'
+import CanvasIcon from '@components/plugin/CanvasMarkers'
+import MagicMarker from '@components/plugin/MagicMarker'
+import WmtsSupport from '@components/plugin/wmts_plugins'
 import 'leaflet.markercluster'
 
 import MapConfig from '@/conf/MapConfig'
-import CommonLayerLoad from '@components/mapmodules/CommonLayerLoad'
-// import DashFlow from '@components/plugin/PathDashFlow'
-// import AjaxUtils from '@/utils/AjaxUtils'
+import DashFlow from '@components/plugin/PathDashFlow'
 let map = null
 // let baseMapGroup = null
-let commonLayerLoad = null
 const initMap = (div) => {
     if (map != null) {
         map.remove()
-        // baseMapGroup = null
-        commonLayerLoad = null
     }
 
     // Leaflet鎵╁睍浠g爜
-    // Editable.init(L) // 鍥惧眰缂栬緫
-    // PathDrag.init(L) // 璺緞鎷栨嫿
-    // MagicMarker.init(L) // 鍔ㄧ敾Marker
-    // CanvasIcon.init(L) // 浣跨敤canvas缁樺埗Marker
-
+    Editable.init(L) // 鍥惧眰缂栬緫
+    PathDrag.init(L) // 璺緞鎷栨嫿
+    MagicMarker.init(L) // 鍔ㄧ敾Marker
+    CanvasIcon.init(L) // 浣跨敤canvas缁樺埗Marker
+    WmtsSupport.init(L) // 鎵╁睍锛屼娇鏀寔WMTS
     // CustomPopup.init(L) // 鑷畾涔夊脊鍑烘
-    // DashFlow.DashFlow(L) // 娴佸姩绾垮浘
+    DashFlow.DashFlow(L) // 娴佸姩绾垮浘
     // Leaflet鎵╁睍浠g爜
 
     map = L.map(div, MapConfig.mapOptions)
 
-    
-    // getToken()
-    // L.control.scale({ maxWidth: 200, metric: true, imperial: false }).addTo(map)
-    // L.control.layers(SgisConfig.baseLayers, SgisConfig.overlayLayers, { position: 'bottomright' }).addTo(map)
-
     window.map = map
     window.L = L
 
-    // showLngLat()
     return { map: map, L: L }
 }
 
-// let getToken = () => {
-//     let params = MapConfig.TokenConfig
-//     AjaxUtils.GetDataAsynByUrl(params.url, params.option, function(token) {
-//         showTdt(token)
-//     })
-// }
-// let showTdt = (token) => {
-//     const imgMapm = commonLayerLoad.loadIntranetImgMap(token)
-//     const imgMapa = commonLayerLoad.loadIntranetImgMapCia(token)
-//     baseMapGroup.addLayer(imgMapm)
-//     baseMapGroup.addLayer(imgMapa)
-// }
-
 /**
- * 鐡︾墖搴曞浘鍒濆鍖�
+ * 鍩虹搴曞浘鍒濆鍖�
  * @param map
+ * @param L
  */
-const initBasemaps = (map, L) => {
+const initBasemapsHelper = (map, L) => {
     // todo 杩欓噷杩涜搴曞浘鍦板浘鐨勫垵濮嬪寲
-    var basemapHelper = new BasemapHelper(map, L)
+    var basemapHelper = new BasemapHelper({map, L})
     return basemapHelper
 }
-
-const initTileLayers = (map, L) => {
-    // DashFlow.DashFlow(L, map)
-    commonLayerLoad = new CommonLayerLoad()
-    // const blueMap = commonLayerLoad.loadBlueMap()
-    // baseMapGroup = L.layerGroup([blueMap]).addTo(map)
-
-    const imgMapm = commonLayerLoad.loadImgMapm()
-    const imgMapa = commonLayerLoad.loadImgMapa()
-    
-    L.layerGroup([imgMapm, imgMapa]).addTo(map)
+/**
+ * 涓氬姟搴曞浘鍒濆鍖�
+ * @param map
+ * @param L
+ */
+const initTileLayersHelper = (map, L) => {
+    let serviceLayerHelper = new ServiceLayerHelper({map, L})
+    return serviceLayerHelper
 }
 
 /**
  * 鐭㈤噺鍦板浘鍒濆鍖�
  * @param map
- */
-/**
- *
- * @param map
  * @param L
- * @param obj { name: 'trackPlayer', ref: this.$refs.trackPlayer }  缁勪欢鐨勫悕绉� 鍜� 缁勪欢鐨勫紩鐢�
- * @param loadMethodNames
  */
-const initVectorLayers = (map, L, obj, env) => {
+const initVectorLayersHelper = (map, L) => {
     // todo 杩欓噷杩涜鍦板浘鐨勫垵濮嬪寲
-    var vectorLayerHelper = new VectorLayerHelper(map, L, env)
-    if (obj != null) {
-        vectorLayerHelper.setVueRef(obj.name, obj.ref)
-    }
-    // let loadMethodNames = ['dock', 'petro', 'fillingStation', 'storeHouse', 'productOil', 'transDisplay', 'ship', 'train', 'warningCar', 'trackQuery', 'weather']
-    vectorLayerHelper.initVectorLayers()
+    var vectorLayerHelper = new VectorLayerHelper({map, L})
     window.vectorLayerHelper = vectorLayerHelper
     return vectorLayerHelper
 }
 
 export default {
     initMap,
-    initBasemaps,
-    initTileLayers,
-    initVectorLayers
+    initBasemapsHelper,
+    initTileLayersHelper,
+    initVectorLayersHelper
 }

--
Gitblit v1.8.0