派生自 wuyushui/SewerAndRainNetwork

wangrui
2020-12-19 44280203af25006efc4b8939b4fc01477041e9b8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import * as L from 'leaflet'
import BasemapHelper from '@components/helpers/BasemapHelper'
import VectorLayerHelper from '@components/helpers/VectorLayerHelper'
 
// 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 'leaflet.markercluster'
 
import MapConfig from '@/conf/MapConfig'
import CommonLayerLoad from '@components/mapmodules/CommonLayerLoad'
// import DashFlow from '@components/plugin/PathDashFlow'
// import AjaxUtils from '@/utils/AjaxUtils'
let map = null
// let baseMapGroup = null
let commonLayerLoad = null
const initMap = (div) => {
    if (map != null) {
        map.remove()
        // baseMapGroup = null
        commonLayerLoad = null
    }
 
    // Leaflet扩展代码
    // Editable.init(L) // 图层编辑
    // PathDrag.init(L) // 路径拖拽
    // MagicMarker.init(L) // 动画Marker
    // CanvasIcon.init(L) // 使用canvas绘制Marker
 
    // CustomPopup.init(L) // 自定义弹出框
    // DashFlow.DashFlow(L) // 流动线图
    // Leaflet扩展代码
 
    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
 */
const initBasemaps = (map, L) => {
    // todo 这里进行底图地图的初始化
    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 map
 * @param L
 * @param obj { name: 'trackPlayer', ref: this.$refs.trackPlayer }  组件的名称 和 组件的引用
 * @param loadMethodNames
 */
const initVectorLayers = (map, L, obj, env) => {
    // 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()
    window.vectorLayerHelper = vectorLayerHelper
    return vectorLayerHelper
}
 
export default {
    initMap,
    initBasemaps,
    initTileLayers,
    initVectorLayers
}