UNPKG

map-integration

Version:

vue集成地图第三方插件

68 lines (63 loc) 2.11 kB
import Vue from 'vue' import Provider from '../leaflet/config' import { LeafletResult } from '../ts/LeafletResult' const L = Vue.prototype.$L const result = new LeafletResult() function initLeaflet(obj) { Provider(L) // 挂载插件 // const origin = [-180, 90] //图层起点坐标,经度偏移,维度偏移 // const resolutions = [ // 1.40625000000024, // Level 0 // 0.703125000000119, // Level 1 // 0.351562500000059, // Level 2 // 0.17578125000003, // Level 3 // 0.0878906250000148, // Level 4 // 0.0439453125000074, // Level 5 // 0.0219726562500037, // Level 6 // 0.0109863281250019, // Level 7 // 0.00549316406250093, // Level 8 // 0.00274658203125046, // Level 9 // 0.00137329101562523, // Level 10 // 0.000686645507812616, // Level 11 // 0.000343322753906308, // Level 12 // 0.000171661376953154, // Level 13 // 8.5830688476577e-5, // Level 14 // 4.29153442382885e-5, // Level 15 // 2.14576721191443e-5, // Level 16 // 1.07288360595721e-5, // Level 17 // 5.36441802978606e-6, // Level 18 // 2.68220901489303e-6, // Level 19 // 1.34110450744652e-6, // Level 20 // ] // const crs = new L.Proj.CRS('EPSG:4326', '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs', { // origin: origin, // resolutions: resolutions, // }) const map = L.map( 'map', Object.assign({}, obj, { center: [obj.center[1], obj.center[0]], zoom: obj.zoom, zoomControl: false, //缩放按钮 attributionControl: false, //地图属性-右下角 maxZoom: obj.maxZoom, // crs: crs, }) ) const normalLayer = L.tileLayer.chinaProvider('TianDiTu.Normal.Map', { maxZoom: obj.maxZoom, minZoom: obj.minZoom, }) const normalLayerAnnotion = L.tileLayer.chinaProvider('TianDiTu.Normal.Annotion', { maxZoom: obj.maxZoom, minZoom: obj.minZoom, }) normalLayer.addTo(map) normalLayerAnnotion.addTo(map) const features = new L.FeatureGroup() map.addLayer(features) result.features = features result.map = map return result } export { initLeaflet }