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 WmtsSupport from '@components/plugin/wmts_plugins' import 'leaflet.markercluster' import MapConfig from '@/conf/MapConfig' import DashFlow from '@components/plugin/PathDashFlow' let map = null // let baseMapGroup = null const initMap = (div) => { if (map != null) { map.remove() } // Leaflet扩展代码 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) // 流动线图 // Leaflet扩展代码 map = L.map(div, MapConfig.mapOptions) map.on('click', (event, a, b) => { console.log(event, a, b) }) window.map = map window.L = L return { map: map, L: L } } /** * 基础底图初始化 * @param map * @param L */ const initBasemapsHelper = (map, L) => { // todo 这里进行底图地图的初始化 var basemapHelper = new BasemapHelper({map, L}) return basemapHelper } /** * 业务底图初始化 * @param map * @param L */ const initTileLayersHelper = (map, L) => { let serviceLayerHelper = new ServiceLayerHelper({map, L}) return serviceLayerHelper } /** * 矢量地图初始化 * @param map * @param L */ const initVectorLayersHelper = (map, L) => { // todo 这里进行地图的初始化 var vectorLayerHelper = new VectorLayerHelper({map, L}) window.vectorLayerHelper = vectorLayerHelper return vectorLayerHelper } export default { initMap, initBasemapsHelper, initTileLayersHelper, initVectorLayersHelper }