index.js (1228B)
1 import L from 'leaflet'; 2 import './TileLayer'; 3 import './Bing'; 4 import './Yandex'; 5 import './Google'; 6 import './WestraPasses'; 7 import './CanvasMarkers'; 8 import './MeasuredLine'; 9 import './RetinaTileLayer'; 10 11 function getTempMap(zoom, fullSize, pixelBounds) { 12 const container = L.DomUtil.create('div', '', document.body); 13 let width, height, center; 14 if (fullSize) { 15 const size = pixelBounds.getSize(); 16 width = size.x; 17 height = size.y; 18 center = pixelBounds.min.add(size.divideBy(2)); 19 center = L.CRS.EPSG3857.pointToLatLng(center, zoom); 20 } else { 21 width = 100; 22 height = 100; 23 center = L.latLng(0, 0); 24 } 25 26 Object.assign(container.style, { 27 width: `${width}px`, 28 height: `${height}px`, 29 position: 'absolute', 30 left: '0', 31 top: '0', 32 visibility: 'hidden', 33 } 34 ); 35 36 const map = L.map(container, {fadeAnimation: false, zoomAnimation: false, inertia: false, maxZoom: 18}); 37 map.setView(center, zoom); 38 return map; 39 } 40 41 function disposeMap(map) { 42 const container = map._container; 43 map.remove(); 44 L.DomUtil.remove(container); 45 } 46 47 export {getTempMap, disposeMap};