qm-map-maplibre-gl 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +162 -0
  2. package/dist/context/mapContext.d.ts +6 -0
  3. package/dist/index.d.ts +20 -0
  4. package/dist/maplibregl/MapWrapper.d.ts +56 -0
  5. package/dist/maplibregl/layer/BaseLayer.d.ts +11 -0
  6. package/dist/maplibregl/layer/LayerGroupWrapper.d.ts +18 -0
  7. package/dist/maplibregl/layer/LayerWrapper.d.ts +12 -0
  8. package/dist/maplibregl/typings/TEvent.d.ts +25 -0
  9. package/dist/maplibregl/typings/TLayerOptions.d.ts +29 -0
  10. package/dist/maplibregl/typings/TMapOptions.d.ts +4 -0
  11. package/dist/qm-map.css +2 -0
  12. package/dist/qm-map.es.js +1547 -0
  13. package/dist/qm-map.umd.js +28 -0
  14. package/dist/utils.d.ts +36 -0
  15. package/dist/widget/BaseWidget/index.d.ts +24 -0
  16. package/dist/widget/Draw/constant.d.ts +57 -0
  17. package/dist/widget/Draw/index.d.ts +17 -0
  18. package/dist/widget/LayerList/index.d.ts +5 -0
  19. package/dist/widget/LayerList/tree/index.d.ts +16 -0
  20. package/dist/widget/Legend/index.d.ts +5 -0
  21. package/dist/widget/MapWidget/index.d.ts +16 -0
  22. package/dist/widget/PopupPanel/index.d.ts +10 -0
  23. package/dist/widget/PopupWrapper/index.d.ts +16 -0
  24. package/dist/widget/Print/MapGenerator/CrosshairManager.d.ts +8 -0
  25. package/dist/widget/Print/MapGenerator/ImageExporter.d.ts +4 -0
  26. package/dist/widget/Print/MapGenerator/MapGenerator.d.ts +26 -0
  27. package/dist/widget/Print/MapGenerator/MarkersManager.d.ts +22 -0
  28. package/dist/widget/Print/MapGenerator/NorthIconManager.d.ts +44 -0
  29. package/dist/widget/Print/MapGenerator/PDFGenerator.d.ts +10 -0
  30. package/dist/widget/Print/MapGenerator/PrintableAreaManager.d.ts +12 -0
  31. package/dist/widget/Print/MapGenerator/SVGExporter.d.ts +3 -0
  32. package/dist/widget/Print/MapGenerator/types.d.ts +58 -0
  33. package/dist/widget/Print/index.d.ts +5 -0
  34. package/dist/widget/Swipe/MapCompare/index.d.ts +43 -0
  35. package/dist/widget/Swipe/MapCompare/sync-maps.d.ts +6 -0
  36. package/dist/widget/Swipe/index.d.ts +5 -0
  37. package/dist/widget/Swipe/modal/index.d.ts +31 -0
  38. package/package.json +63 -0
@@ -0,0 +1,28 @@
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("react/jsx-runtime"),require("maplibre-gl"),require("react-dom"),require("@mapbox/mapbox-gl-draw"),require("@turf/area")):typeof define==`function`&&define.amd?define([`exports`,`react`,`react/jsx-runtime`,`maplibre-gl`,`react-dom`,`@mapbox/mapbox-gl-draw`,`@turf/area`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.QmMap={},e.react,e.react_jsx_runtime,e.maplibre_gl,e[`react-dom`],e._mapbox_mapbox_gl_draw,e._turf_area))})(this,function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,p=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=u(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&c(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=l(t,s))||r.enumerable});return e},m=(e,t,n)=>(n=e==null?{}:s(d(e)),p(t||!e||!e.__esModule?c(n,`default`,{value:e,enumerable:!0}):n,e));t=m(t,1),a=m(a,1),o=m(o,1);var h={Swipe:`data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTi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};return(0,n.jsxs)(`div`,{className:`maplibregl-control`,style:m,children:[(0,n.jsxs)(`div`,{className:`maplibregl-bar`,children:[(0,n.jsx)(`div`,{className:`maplibregl-bar-button`,onClick:()=>{l?(l(!f),p(!f)):d(!u)},title:a??``,style:{backgroundImage:`url(${o})`}}),a&&(0,n.jsx)(`div`,{className:`maplibregl-bar-title`,children:a})]}),u&&i]})});function _(e,t=new WeakMap){if(typeof e!=`object`||!e)return e;if(t.has(e))return t.get(e);let n;return e instanceof Date?n=new Date(e.getTime()):e instanceof RegExp?(n=new RegExp(e.source,e.flags),n.lastIndex=e.lastIndex):e instanceof Map?(n=new Map,t.set(e,n),e.forEach((e,r)=>{n.set(_(r,t),_(e,t))})):e instanceof Set?(n=new Set,t.set(e,n),e.forEach(e=>{n.add(_(e,t))})):Array.isArray(e)?(n=[],t.set(e,n),e.forEach((e,r)=>{n[r]=_(e,t)})):(n=Object.create(Object.getPrototypeOf(e)),t.set(e,n),Reflect.ownKeys(e).forEach(r=>{let i=e[r];n[r]=_(i,t)})),n}var v=(e,t)=>{let n=null;return r=>{n&&clearTimeout(n),n=setTimeout(()=>{e(r)},t)}},y=(e,t)=>{Array.isArray(t)&&t.length>0&&t.forEach(t=>{e.push(t),t.layers instanceof Array&&y(e,t.layers)})},b=(e,t)=>{t[0]instanceof Array?t.forEach(t=>{t[0]instanceof Array?b(e,t):e.extend(t)}):e.extend(t)},x=e=>{let t=new r.LngLatBounds;return b(t,e.geometry.coordinates),t},S=class{_options;get options(){return this._options}constructor(e){this._options=e}onAdd(e,t){if(this._options.isAdd===!1){this._options.isAdd=!1;return}t=e.findValidBeforeId(this._options.id),this.add(e,t),this._options.isAdd=!0}onRemove(e,t){if(this._options.isAdd)return;e.getLayer(this._options.id)&&e.removeLayer(this._options.id);let n=this._options.id+`-ds`;t&&e.removeSource(n),this._options.isAdd=!1}},C=class extends S{constructor(e){super(e),this._options=e}add(e,t){let{id:n,source:r}=this._options,i=this._options.id+`-ds`;typeof r==`string`&&(i=r),!e.getSource(i)&&r&&typeof r!=`string`&&e.addSource(i,r);let a=e.getLayer(n),o=e.getSource(i);if(!a&&o){let n={...this._options,source:i};e.addLayer(n,t)}}},w=class e{_options;get options(){return this._options}_layers=[];get layers(){return this._layers}constructor(t){this._options=t,t.layers.forEach(t=>{let n;n=`layers`in t?new e(t):new C(t),this._layers.push(n)})}onAdd(e,t){this._layers.forEach(n=>{e.addLayerWrapper(n,t)}),this.updateOptions()}onRemove(e){this._layers.forEach(t=>{e.removeLayerWrapper(t,!1)}),this.updateOptions()}updateOptions(){let e=this._layers.findIndex(e=>e.options.isAdd)>-1;this._options.isAdd=e}},T={MAPINITED:`MAPINITED`,MAPCLICKED:`MAPCLICKED`,MAPLAYERCHANGED:`MAPLAYERCHANGED`,MAPDESTRORY:`MAPDESTRORY`},E=class extends r.Map{_id;get id(){return this._id}_options;get options(){return this._options}_mapLayerSetting;get mapLayerSetting(){return this._mapLayerSetting}_images=[];get images(){return this._images}_layers=[];get layers(){return this._layers}constructor(e){super(e),this._options=e,this._id=e.id,this._mapLayerSetting=[],this.fire(T.MAPINITED,{map:this})}getLayerWrapper(e,t){for(let n of e)if(n.options.id===t)return n;else if(`layers`in n){let e=this.getLayerWrapper(n.layers,t);if(e)return e}}addLayerWrapper(e,t){e.onAdd(this,t),this.fire(T.MAPLAYERCHANGED,{map:this,layer:e})}removeLayerWrapper(e,t){e.onRemove(this,t),this.fire(T.MAPLAYERCHANGED,{map:this,layer:e})}load(e){this._mapLayerSetting=e,e.forEach(e=>{let t;t=`layers`in e?new w(e):new C(e),this.addLayerWrapper(t),this._layers.push(t)})}selectFeature(e){this.clearSelect();let t=`location-ds`;this.addSource(t,{type:`geojson`,data:e}),this.addLayer({id:`location-lyr`,type:`line`,paint:{"line-color":`#00ffff`,"line-width":2},source:t})}clearSelect(){let e=`location-lyr`;this.getLayer(e)&&(this.removeLayer(e),this.removeSource(`location-ds`))}findValidBeforeId(e){let t=this.getLayerList(),n=t.findIndex(t=>t.options.id===e);if(n>-1)for(let e=n;e<t.length;e++){let n=this.getLayer(t[e].options.id);if(n)return n.id}}getLayerList(){let e=[];return y(e,this.layers),e}destory(){this.fire(T.MAPDESTRORY,{map:this}),this.remove()}},D=(0,t.createContext)({map:null}),O=()=>{let e=(0,t.useContext)(D);if(!e)throw Error(`只能在函数组件中使用`);return e};function k(e){let{mapOptions:r,mapLayerSettting:i,children:a,onMapLoad:o,className:s}=e,c=(0,t.useRef)(null),[l,u]=(0,t.useState)(!1),{current:d}=(0,t.useRef)({map:null});return(0,t.useEffect)(()=>{let e=new E({pitch:0,bearing:0,doubleClickZoom:!1,attributionControl:!1,renderWorldCopies:!1,trackResize:!0,...r,container:c.current,style:{version:8,glyphs:`/font/{fontstack}/{range}.pbf`,sources:{},layers:[]}}),t=()=>{e.load(_(i)),u(!0),o?.(e),d&&(d.map=e)};e.on(`load`,t),e.on(`click`,()=>{console.log(`center:`,e.getCenter(),`zoom:`,e.getZoom())});let n=v(()=>{e.resize()},10);return new ResizeObserver(n).observe(c?.current),()=>{e.off(`load`,t)}},[]),(0,n.jsx)(`div`,{ref:c,className:s??`map-wrapper`,id:`map-wrapper`,children:l&&d&&(0,n.jsx)(D.Provider,{value:d,children:a})})}var A=(0,t.memo)(k),j=(e,t)=>{for(let n of e){if(n.key===t)return n;if(n.children){let e=j(n.children,t);if(e)return e}}return null},M=e=>{let t=[];return e.children&&e.children.length>0&&e.children.forEach(e=>{t.push(e.key),t.push(...M(e))}),t},N=e=>!e.children||e.children.length===0,ee=(e,t)=>t.includes(e.key),te=(e,t)=>{if(N(e))return!1;let n=M(e);if(n.length===0)return!1;let r=n.filter(e=>t.includes(e));return r.length>0&&r.length<n.length},P=(0,t.memo)(e=>{let{node:r,level:i,checkedKeys:a,checkable:o,onCheck:s}=e,[c,l]=(0,t.useState)(!0),u=!N(r),d=ee(r,a),f=te(r,a);return(0,n.jsxs)(`div`,{className:`qm-tree-node`,children:[(0,n.jsxs)(`div`,{className:`qm-tree-node-content`,style:{paddingLeft:i*18},children:[(0,n.jsx)(`span`,{className:`qm-tree-switcher ${u?``:`qm-tree-switcher-noop`} ${c?`qm-tree-switcher-expanded`:``}`,onClick:()=>{u&&l(!c)},children:u&&(0,n.jsx)(`svg`,{viewBox:`0 0 1024 1024`,width:`12`,height:`12`,fill:`currentColor`,children:(0,n.jsx)(`path`,{d:`M715.8 493.5L435.6 213.3c-12.4-12.4-32.8-12.4-45.2 0s-12.4 32.8 0 45.2l245.8 245.8-245.8 245.8c-12.4 12.4-12.4 32.8 0 45.2 6.2 6.2 14.3 9.3 22.6 9.3s16.4-3.1 22.6-9.3l280.2-280.2c12.4-12.4 12.4-32.8 0-45.2z`})})}),o&&(0,n.jsx)(`span`,{className:`qm-tree-checkbox ${d?`qm-tree-checkbox-checked`:``} ${f?`qm-tree-checkbox-indeterminate`:``}`,onClick:()=>{s(r.key)},children:(0,n.jsxs)(`span`,{className:`qm-tree-checkbox-inner`,children:[d&&(0,n.jsx)(`svg`,{viewBox:`0 0 1024 1024`,width:`10`,height:`10`,fill:`white`,children:(0,n.jsx)(`path`,{d:`M912 224l-448 448-192-192-64 64 256 256 512-512z`})}),f&&(0,n.jsx)(`span`,{className:`qm-tree-checkbox-indeterminate-icon`})]})}),(0,n.jsx)(`span`,{className:`qm-tree-node-title`,title:typeof r.title==`string`?r.title:``,children:r.title})]}),u&&c&&(0,n.jsx)(`div`,{className:`qm-tree-children`,children:r.children.map(e=>(0,n.jsx)(P,{node:e,level:i+1,checkedKeys:a,checkable:o,onCheck:s},e.key))})]})}),F=(0,t.memo)(e=>{let{treeData:r,checkable:i=!1,checkedKeys:a,onCheck:o,style:s}=e,[c,l]=(0,t.useState)([]),u=a!==void 0,d=u?a:c,f=(e,t)=>{let n=j(r,t);if(!n)return e;let i=e.includes(t),a;if(i){let r=M(n),i=new Set([t,...r]);a=e.filter(e=>!i.has(e))}else{let r=M(n);a=Array.from(new Set([...e,t,...r]))}return a},p=(0,t.useCallback)(e=>{if(u){let t=f(d,e);o?.(t)}else l(t=>{let n=f(t,e);return o?.(n),n})},[d,r,u,o]);return(0,n.jsx)(`div`,{className:`qm-tree`,style:s,children:r.map(e=>(0,n.jsx)(P,{node:e,level:0,checkedKeys:d,checkable:i,onCheck:p},e.key))})}),I=(0,t.memo)(e=>{let[r,i]=(0,t.useState)([]),{map:a}=O(),[o,s]=(0,t.useState)([]),c=(0,t.useCallback)((e,t)=>{let n,r=[];return e.forEach(e=>{n=void 0,n=`layers`in e&&e.options.type===`logicGroup`?{title:e.options.name,key:e.options.id,selectable:!1,children:c(e.layers,t)}:{title:e.options.name,key:e.options.id,selectable:!1},n&&r.push(n),e.options.isAdd&&e.options.type!==`logicGroup`&&t.push(e.options.id)}),r},[]),l=e=>{i(e);let t=new Set([...r,...e]),n=new Set([...t].filter(e=>!r.includes(e))),o=new Set([...t].filter(t=>!e.includes(t)));n.forEach(e=>{let t=a?.getLayerWrapper(a.layers,e);t&&`layers`in t?(t.layers.forEach(e=>{e.options.isAdd=!0}),a?.addLayerWrapper(t)):t&&(t.options.isAdd=!0,a?.addLayerWrapper(t))}),o.forEach(e=>{let t=a?.getLayerWrapper(a.layers,e);t&&`layers`in t?(t.layers.forEach(e=>{e.options.isAdd=!1}),a?.removeLayerWrapper(t)):t&&(t.options.isAdd=!1,a?.removeLayerWrapper(t))}),a.layers.forEach(e=>{u(e)})},u=e=>{`layers`in e&&e.layers.findIndex(e=>e.options.type===`logicGroup`)>-1?e.layers.forEach(e=>{u(e)}):`layers`in e&&e.options.type===`logicGroup`&&(e.layers.findIndex(e=>e.options.isAdd)===-1?e.options.isAdd=!1:e.options.isAdd=!0)};return(0,t.useEffect)(()=>{let e=()=>{let e=[];s(a?c(a.layers,e):[]),i(e)},t=v(()=>{e()},300);return a?.on(T.MAPLAYERCHANGED,t),e(),()=>{a?.off(T.MAPLAYERCHANGED,t)}},[]),(0,n.jsx)(g,{name:`图层控制`,position:e.position,icon:h.LayerList,width:200,height:r.length*28<280?280:r.length*28,children:(0,n.jsx)(F,{checkable:!0,checkedKeys:r,onCheck:e=>l(e),treeData:o,style:{fontSize:12,maxHeight:400,overflowX:`hidden`,overflowY:`auto`}})})}),L=(0,t.memo)(e=>{let{map:r}=O(),[i,a]=(0,t.useState)(),[o,s]=(0,t.useState)(0),c=(0,t.useCallback)((e,t,i)=>{let a;e.forEach(e=>{if(a=void 0,`layers`in e&&!e.options.legend)c(e.layers,t,i);else if(e.options.legend&&(e.options.isAdd||`layers`in e&&e.layers.filter(e=>e.options.isAdd).length)){let{title:i,items:o}=e.options.legend;if(o)a=(0,n.jsxs)(`div`,{className:`maplibregl-legend-group`,children:[(0,n.jsx)(`div`,{className:`maplibregl-legend-tilte`,children:i||e.options.name}),o?.map(e=>{t.push(26);let i=r?.images.find(t=>t.id===e.imageId);return(0,n.jsxs)(`div`,{className:`maplibregl-legend-item`,children:[i?(0,n.jsx)(`img`,{src:i.data,alt:``,className:`maplibregl-legend-item-img`}):(0,n.jsx)(`div`,{className:`maplibregl-legend-item-geo`,style:e.style}),(0,n.jsx)(`div`,{className:`maplibregl-legend-item-text`,children:e.text})]},e.text)})]},e.options.id),t.push(50);else{let{style:o,imageId:s,text:c}=e.options.legend,l=r?.images.find(e=>e.id===s);t.push(26),a=(0,n.jsxs)(`div`,{className:`maplibregl-legend-item`,children:[l?(0,n.jsx)(`img`,{src:l.data,alt:``,className:`maplibregl-legend-item-img`}):(0,n.jsx)(`div`,{className:`maplibregl-legend-item-geo`,style:o}),(0,n.jsx)(`div`,{className:`maplibregl-legend-item-text`,children:c||e.options.name})]},c||i||e.options.id)}}else a=void 0;a&&i.push(a)})},[]);return(0,t.useEffect)(()=>{let e=()=>{let e=[],t=[];c(r.layers,e,t),a(t),s(e.reduce((e,t)=>e+t,0)+40)},t=v(()=>{e()},200);return r?.on(T.MAPLAYERCHANGED,t),e(),()=>{r?.off(T.MAPLAYERCHANGED,t)}},[]),(0,n.jsx)(g,{name:`图例`,position:e.position,icon:h.Legend,width:180,height:o,children:(0,n.jsx)(`div`,{className:`maplibregl-legend`,children:i})})}),R={JPEG:`jpg`,PNG:`png`,PDF:`pdf`,SVG:`svg`},z={mm:`mm`},B={A2:[594,420],A3:[420,297],A4:[297,210],A5:[210,148],A6:[148,105],B2:[707,500],B3:[500,353],B4:[353,250],B5:[250,176],B6:[176,125],Letter:[279,216]},V={横向:`landscape`,纵向:`portrait`},H={72:72,96:96,200:200,300:300,400:400},U=class{map;svgCanvas;constructor(e){this.map=e,this.svgCanvas=null}create(){if(!this.map)return;let e=this.map.getCanvasContainer(),t=this.map.getCanvas().clientWidth,n=this.map.getCanvas().clientHeight,r=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);r.setAttribute(`class`,`qm-print-crosshair`),r.style.cssText=`position:absolute;top:0;left:0;width:${t}px;height:${n}px;pointer-events:none;`;let i=t/2,a=n/2,o=document.createElementNS(`http://www.w3.org/2000/svg`,`line`);o.setAttribute(`x1`,`${i}`),o.setAttribute(`y1`,`0`),o.setAttribute(`x2`,`${i}`),o.setAttribute(`y2`,`${n}`),o.setAttribute(`stroke`,`#dddddd`),o.setAttribute(`stroke-width`,`2`),o.setAttribute(`stroke-dasharray`,`5,5`);let s=document.createElementNS(`http://www.w3.org/2000/svg`,`line`);s.setAttribute(`x1`,`0`),s.setAttribute(`y1`,`${a}`),s.setAttribute(`x2`,`${t}`),s.setAttribute(`y2`,`${a}`),s.setAttribute(`stroke`,`#dddddd`),s.setAttribute(`stroke-width`,`2`),s.setAttribute(`stroke-dasharray`,`5,5`),r.appendChild(o),r.appendChild(s),e.appendChild(r),this.svgCanvas=r}destroy(){this.svgCanvas?.remove(),this.svgCanvas=null,this.map=null}},W=class{map;svgCanvas;path;constructor(e){this.map=e,this.svgCanvas=null,this.path=null}updateArea(e,t,n=z.mm){if(!this.map||!this.svgCanvas)return;let r=this.map.getCanvas().clientWidth,i=this.map.getCanvas().clientHeight,a=this.toPixels(e,n),o=this.toPixels(t,n),s=r/a,c=i/o,l=Math.min(s,c,1),u=a*l,d=o*l,f=(r-u)/2,p=(i-d)/2,m=f+u,h=p+d,g=`M 0 0 L ${r} 0 L ${r} ${i} L 0 ${i} Z M ${f} ${p} L ${m} ${p} L ${m} ${h} L ${f} ${h} Z`;this.path?.setAttribute(`d`,g)}create(){if(!this.map)return;let e=this.map.getCanvasContainer(),t=this.map.getCanvas().clientWidth,n=this.map.getCanvas().clientHeight,r=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);r.style.cssText=`position:absolute;top:0;left:0;width:${t}px;height:${n}px;pointer-events:none;`;let i=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);i.setAttribute(`fill`,`#888888`),i.setAttribute(`fill-opacity`,`0.5`),i.setAttribute(`stroke-width`,`0`),i.setAttribute(`fill-rule`,`evenodd`),r.appendChild(i),e.appendChild(r),this.svgCanvas=r,this.path=i}destroy(){this.svgCanvas?.remove(),this.svgCanvas=null,this.path=null,this.map=null}toPixels(e,t){return t===z.mm?96/25.4*e:96*e}},G=class{toPNG(e,t){e.toBlob(e=>{if(e){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n)}})}toJPEG(e,t,n=.85){let r=document.createElement(`canvas`);r.width=e.width,r.height=e.height;let i=r.getContext(`2d`);i&&(i.fillStyle=`#FFFFFF`,i.fillRect(0,0,r.width,r.height),i.drawImage(e,0,0));let a=r.toDataURL(`image/jpeg`,Math.max(0,Math.min(1,n))),o=document.createElement(`a`);o.href=a,o.download=t,o.click()}},K=`<svg width="800px" height="800px" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--gis" preserveAspectRatio="xMidYMid meet"><path d="M47.655 1.634l-35 95c-.828 2.24 1.659 4.255 3.68 2.98l33.667-21.228l33.666 21.228c2.02 1.271 4.503-.74 3.678-2.98l-35-95C51.907.514 51.163.006 50 .008c-1.163.001-1.99.65-2.345 1.626zm-.155 14.88v57.54L19.89 91.461z" fill="none" stroke="white" stroke-width="1.5"/><path d="M47.655 1.634l-35 95c-.828 2.24 1.659 4.255 3.68 2.98l33.667-21.228l33.666 21.228c2.02 1.271 4.503-.74 3.678-2.98l-35-95C51.907.514 51.163.006 50 .008c-1.163.001-1.99.65-2.345 1.626zm-.155 14.88v57.54L19.89 91.461z" fill="#000000" fill-rule="evenodd"></path></svg>`,q={image:K,imageName:`gl-export-north-icon`,imageSizeFraction:.05,visibility:`visible`,position:`top-right`},J=class{options;constructor(e){this.options={...q,...e,image:e?.image??K}}async addToMap(e,t,n){let r=this.options.visibility??`visible`;e.getZoom()<2&&t>n&&(r=`none`),await this.addNorthIconImage(e);let i=this.getIconWidth(e,this.options.imageSizeFraction??.08)*.8,a=this.getElementPosition(e,this.options.position??`top-right`,i),o=e.unproject(a),s=this.options.imageName??`gl-export-north-icon`;e.addSource(s,{type:`geojson`,data:{type:`Feature`,geometry:{type:`Point`,coordinates:[o.lng,o.lat]},properties:{}}}),e.addLayer({id:s,source:s,type:`symbol`,layout:{"icon-image":s,"icon-size":1,"icon-rotate":e.getBearing()*-1,"icon-allow-overlap":!0,"icon-ignore-placement":!0,visibility:r},paint:{}})}async addNorthIconImage(e){let t=this.getIconWidth(e,this.options.imageSizeFraction??.08);return new Promise(n=>{let r=new Image(t,t);r.onload=()=>{this.options.imageName&&e.addImage(this.options.imageName,r),n()};function i(e){return`data:image/svg+xml;charset=utf-8,`+encodeURIComponent(e)}this.options.image&&(r.src=i(this.options.image))})}getIconWidth(e,t){let n=e.getContainer(),r=parseInt(n.style.width.replace(`px`,``));return parseInt(`${r*t}`)}getElementPosition(e,t,n=0){let r=e.getContainer(),i=0,a=0;switch(t){case`top-left`:i=0+n,a=0+n;break;case`top-right`:i=parseInt(r.style.width.replace(`px`,``))-n,a=0+n;break;case`bottom-left`:i=0+n,a=parseInt(r.style.height.replace(`px`,``))-n;break;case`bottom-right`:i=parseInt(r.style.width.replace(`px`,``))-n,a=parseInt(r.style.height.replace(`px`,``))-n;break;default:break}return[i,a]}updateOptions(e){this.options={...this.options,...e,image:e.image??this.options.image}}},Y={"circle-radius":8,"circle-color":`red`,"circle-stroke-width":1,"circle-stroke-color":`black`},X=`maplibregl-marker`,ne=class{sourceMap;renderMap;markerClassName;markerCirclePaint;constructor(e,t,n){this.sourceMap=e,this.renderMap=t,this.markerClassName=n?.markerClassName??X,this.markerCirclePaint={...Y,...n?.markerCirclePaint}}getMarkers(){return this.sourceMap.getCanvasContainer().getElementsByClassName(this.markerClassName)}renderMarkers(){let e=this.getMarkers(),t=e.length;if(t===0)return!1;for(let n=0;n<t;n++){let t=e.item(n);if(!t)continue;let r=t.getAttribute(`style`);if(!r)continue;let i=r.match(/translate\(([^,]+)px,\s*([^,]+)px\)/);if(!i)continue;let a=parseInt(i[1]),o=parseInt(i[2]),s=this.sourceMap.unproject([a,o]),c=`print-marker-${n}`;this.renderMap.addSource(c,{type:`geojson`,data:{type:`Point`,coordinates:[s.lng,s.lat]}}),this.renderMap.addLayer({id:c,source:c,type:`circle`,paint:this.markerCirclePaint})}return!0}},re=class{width;height;unit;constructor(e,t,n){this.width=e,this.height=t,this.unit=n}generate(e,t){let n=this.buildPDF(e),r=new Blob([n],{type:`application/pdf`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,a.click(),URL.revokeObjectURL(i)}buildPDF(e){let t=this.unit===z.mm?this.width*2.83465:this.width*72,n=this.unit===z.mm?this.height*2.83465:this.height*72,r=document.createElement(`canvas`);r.width=e.width,r.height=e.height;let i=r.getContext(`2d`);i&&(i.fillStyle=`#FFFFFF`,i.fillRect(0,0,r.width,r.height),i.drawImage(e,0,0));let a=r.toDataURL(`image/jpeg`,.92).split(`,`)[1],o=atob(a),s=new Uint8Array(o.length);for(let e=0;e<o.length;e++)s[e]=o.charCodeAt(e);return this.createPDFStructure(t,n,e.width,e.height,s)}createPDFStructure(e,t,n,r,i){let a=Math.round(e),o=Math.round(t),s=i.length,c=0,l=c;c+=49;let u=c;c+=57;let d=`3 0 obj\n<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${a} ${o}] /Contents 4 0 R /Resources << /XObject << /Im0 5 0 R >> >> >>\nendobj\n`,f=c;c+=d.length;let p=`q\n${a} 0 0 ${o} 0 0 cm\n/Im0 Do\nQ\n`,m=`4 0 obj\n<< /Length ${p.length} >>\nstream\n${p}endstream\nendobj\n`,h=c;c+=m.length;let g=`5 0 obj\n<< /Type /XObject /Subtype /Image /Width ${n} /Height ${r} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length ${s} >>\nstream\n`,_=c;c+=g.length+s+18;let v=c,y=`xref\n0 6\n0000000000 65535 f \n${String(l).padStart(10,`0`)} 00000 n \n${String(u).padStart(10,`0`)} 00000 n \n${String(f).padStart(10,`0`)} 00000 n \n${String(h).padStart(10,`0`)} 00000 n \n${String(_).padStart(10,`0`)} 00000 n \n`,b=`trailer\n<< /Size 6 /Root 1 0 R >>\nstartxref\n${v}\n%%EOF`,x=new TextEncoder,S=[x.encode(`%PDF-1.4
2
+ `),x.encode(`1 0 obj
3
+ << /Type /Catalog /Pages 2 0 R >>
4
+ endobj
5
+ `),x.encode(`2 0 obj
6
+ << /Type /Pages /Kids [3 0 R] /Count 1 >>
7
+ endobj
8
+ `),x.encode(d),x.encode(m),x.encode(g),i,x.encode(`
9
+ endstream
10
+ endobj
11
+ `),x.encode(y),x.encode(b)],C=S.reduce((e,t)=>e+t.length,0),w=new Uint8Array(C),T=0;for(let e of S)w.set(e,T),T+=e.length;return w.buffer}},ie=class{toSVG(e,t,n,r,i,a){let o=e.toDataURL(`image/png`),s=i===`mm`?a/25.4:a,c=s*n,l=s*r,u=`
12
+ <svg xmlns="http://www.w3.org/2000/svg"
13
+ xmlns:xlink="http://www.w3.org/1999/xlink"
14
+ version="1.1"
15
+ width="${c}"
16
+ height="${l}"
17
+ viewBox="0 0 ${c} ${l}"
18
+ xml:space="preserve">
19
+ <image xlink:href="${o}" width="${c}" height="${l}"></image>
20
+ </svg>`,d=`data:application/xml,${encodeURIComponent(u)}`,f=document.createElement(`a`);f.href=d,f.download=t,f.click()}},ae=class{map;width;height;dpi;format;unit;jpegQuality;northIcon;northIconOptions;markerOptions;constructor(e,t,n,r,i=z.mm,a){this.map=e,this.width=t[0],this.height=t[1],this.dpi=n,this.format=r,this.unit=i,this.jpegQuality=a?.jpegQuality??.85,this.northIcon=a?.northIcon??!1,this.northIconOptions=a?.northIconOptions,this.markerOptions=a?.markerOptions??{}}generate(e){this.showLoading();let t=window.devicePixelRatio;Object.defineProperty(window,"devicePixelRatio",{get:()=>this.dpi/96});let n=document.createElement(`div`);n.className=`qm-print-hidden-container`,n.style.cssText=`
21
+ position: fixed;
22
+ top: 0;
23
+ left: 0;
24
+ width: 100%;
25
+ height: 100%;
26
+ visibility: hidden;
27
+ pointer-events: none;
28
+ `;let i=document.createElement(`div`),a=this.toPixels(this.width),o=this.toPixels(this.height);i.style.cssText=`position:absolute;top:0;left:0;width:${a}px;height:${o}px;`,n.appendChild(i),document.body.appendChild(n);let s=new r.Map({container:i,style:this.map.getStyle(),center:this.map.getCenter(),zoom:this.map.getZoom(),bearing:this.map.getBearing(),pitch:this.map.getPitch(),interactive:!1,fadeDuration:0,attributionControl:!1,canvasContextAttributes:{preserveDrawingBuffer:!0},transformRequest:this.map._requestManager._transformRequestFn});this.map.getTerrain()&&(s.setMaxPitch(85),s.setPitch(this.map.getPitch()));let c=this.map.style?.imageManager?.images||[];Object.keys(c).forEach(e=>{s.hasImage(e)||s.addImage(e,c[e].data)});let l=()=>new Promise(e=>{if(!s.isStyleLoaded()||!s.areTilesLoaded()){setTimeout(l,100);return}setTimeout(e,200)});s.once(`idle`,async()=>{await l(),this.northIcon&&(await new J(this.northIconOptions).addToMap(s,this.width,this.height),await new Promise(e=>{s.once(`idle`,()=>{setTimeout(e,200)})})),new ne(this.map,s,this.markerOptions).renderMarkers()&&await new Promise(e=>{s.once(`idle`,()=>{setTimeout(e,200)})});let r=s.getCanvas(),i=r.getContext(`webgl`)||r.getContext(`webgl2`);i&&i.readPixels(0,0,1,1,i.RGBA,i.UNSIGNED_BYTE,new Uint8Array(4));let a=`map.${this.format}`,o=new G;switch(this.format){case R.PNG:o.toPNG(r,a);break;case R.JPEG:o.toJPEG(r,a,this.jpegQuality);break;case R.PDF:new re(this.width,this.height,this.unit).generate(r,a);break;case R.SVG:new ie().toSVG(r,a,this.width,this.height,this.unit,this.dpi);break}s.remove(),n.remove(),Object.defineProperty(window,"devicePixelRatio",{get:()=>t}),this.hideLoading(),e?.()})}toPixels(e){return this.unit===z.mm?96/25.4*e:96*e}showLoading(){let e=document.createElement(`div`);e.className=`qm-print-loading-overlay`,e.innerHTML=`<div class="qm-print-loading-spinner"></div><div class="qm-print-loading-text">正在生成...</div>`,document.body.appendChild(e)}hideLoading(){document.querySelector(`.qm-print-loading-overlay`)?.remove()}},oe=(0,t.memo)(e=>{let{map:r}=O(),[i,a]=(0,t.useState)(!1),[o,s]=(0,t.useState)({PageSize:B.A4,PageOrientation:V.横向,Format:R.PDF,DPI:H[300],Crosshair:!0,PrintableArea:!0}),c=(0,t.useRef)(null),l=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(r)return i?(o.Crosshair&&(c.current=new U(r),c.current.create()),o.PrintableArea&&(l.current=new W(r),l.current.create()),u()):(c.current?.destroy(),c.current=null,l.current?.destroy(),l.current=null),()=>{c.current?.destroy(),l.current?.destroy()}},[r,i,o.Crosshair,o.PrintableArea,o.PageSize,o.PageOrientation]);let u=(0,t.useCallback)(()=>{if(!l.current)return;let e=o.PageSize;o.PageOrientation===V.纵向?l.current.updateArea(e[1],e[0]):l.current.updateArea(e[0],e[1])},[o.PageSize,o.PageOrientation]),d=(0,t.useCallback)(()=>{if(!r)return;let e=[...o.PageSize];o.PageOrientation===V.纵向&&(e=[e[1],e[0]]),new ae(r,e,o.DPI,o.Format,z.mm,{jpegQuality:o.JPEGQuality,northIcon:!0}).generate(()=>{a(!1)})},[r,o]),f=e=>{console.log(`打印面板:`,e),a(e)},p=Object.entries(B).map(([e,t])=>(0,n.jsx)(`option`,{value:JSON.stringify(t),children:e},e)),m=Object.entries(V).map(([e,t])=>(0,n.jsx)(`option`,{value:t,children:e},e)),_=Object.entries(R).map(([e,t])=>(0,n.jsx)(`option`,{value:t,children:e},e)),v=Object.entries(H).map(([e,t])=>(0,n.jsx)(`option`,{value:t,children:e},e));return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(g,{name:`打印`,position:e.position,icon:h.Print,openHandle:f,children:(0,n.jsx)(n.Fragment,{})}),(0,n.jsxs)(`div`,{className:`qm-print-panel ${i?`open`:``}`,style:{position:`absolute`,top:(e.position.top??0)+34,right:e.position.right??10},children:[(0,n.jsx)(`table`,{className:`qm-print-panel-table`,children:(0,n.jsxs)(`tbody`,{children:[(0,n.jsxs)(`tr`,{children:[(0,n.jsx)(`td`,{children:(0,n.jsx)(`label`,{children:`页面尺寸`})}),(0,n.jsx)(`td`,{children:(0,n.jsx)(`select`,{id:`print-page-size`,value:JSON.stringify(o.PageSize),onChange:e=>{s(t=>({...t,PageSize:JSON.parse(e.target.value)})),u()},children:p})})]}),(0,n.jsxs)(`tr`,{children:[(0,n.jsx)(`td`,{children:(0,n.jsx)(`label`,{children:`布局方向`})}),(0,n.jsx)(`td`,{children:(0,n.jsx)(`select`,{id:`print-orientation`,value:o.PageOrientation,onChange:e=>{s(t=>({...t,PageOrientation:e.target.value})),u()},children:m})})]}),(0,n.jsxs)(`tr`,{children:[(0,n.jsx)(`td`,{children:(0,n.jsx)(`label`,{children:`导出格式`})}),(0,n.jsx)(`td`,{children:(0,n.jsx)(`select`,{id:`print-format`,value:o.Format,onChange:e=>s(t=>({...t,Format:e.target.value})),children:_})})]}),(0,n.jsxs)(`tr`,{children:[(0,n.jsx)(`td`,{children:(0,n.jsx)(`label`,{children:`DPI`})}),(0,n.jsx)(`td`,{children:(0,n.jsx)(`select`,{id:`print-dpi`,value:o.DPI,onChange:e=>s(t=>({...t,DPI:Number(e.target.value)})),children:v})})]})]})}),(0,n.jsx)(`button`,{type:`button`,className:`qm-print-export-button`,onClick:d,children:`导 出`})]})]})});function se(e,t){let n=e.getCenter(),r=e.getZoom(),i=e.getBearing(),a=e.getPitch();t.forEach(e=>{e.jumpTo({center:n,zoom:r,bearing:i,pitch:a})})}function ce(...e){let t;t=e.length===1&&Array.isArray(e[0])?e[0]:e;let n=[];t.forEach((e,r)=>{let i=t.filter((e,t)=>t!==r);n[r]=()=>a(e,i)});function r(){t.forEach((e,t)=>{e.on(`move`,n[t])})}function i(){t.forEach((e,t)=>{e.off(`move`,n[t])})}function a(e,t){i(),se(e,t),r()}return r(),()=>{i()}}var Z=class{options;_mapA;_mapB;_horizontal;_bounds;currentPosition=0;_swiper;_controlContainer;_clearSync;_onResize;_eventTarget;constructor(e,t,n,r={}){this.options={orientation:`vertical`,mousemove:!1,...r},this._mapA=e,this._mapB=t,this._horizontal=this.options.orientation===`horizontal`,this._eventTarget=new EventTarget,this._swiper=document.createElement(`div`),this._swiper.className=this._horizontal?`compare-swiper-horizontal`:`compare-swiper-vertical`,this._controlContainer=document.createElement(`div`),this._controlContainer.className=this._horizontal?`maplibregl-compare maplibregl-compare-horizontal`:`maplibregl-compare`,this._controlContainer.appendChild(this._swiper),this._mountContainer(n),this._bounds=this._mapB.getContainer().getBoundingClientRect();let i=this._horizontal?this._bounds.height/2:this._bounds.width/2;this._setPosition(i),this._clearSync=ce(this._mapA,this._mapB),this._onResize=()=>{this._bounds=this._mapB.getContainer().getBoundingClientRect(),this.currentPosition&&this._setPosition(this.currentPosition)},this._mapB.on(`resize`,this._onResize),this.options.mousemove&&(this._mapA.getContainer().addEventListener(`mousemove`,this._onMove),this._mapB.getContainer().addEventListener(`mousemove`,this._onMove)),this._swiper.addEventListener(`mousedown`,this._onDown),this._swiper.addEventListener(`touchstart`,this._onDown)}_mountContainer(e){if(typeof e==`string`){let t=document.querySelector(e);if(!t)throw Error(`找不到容器`);t.appendChild(this._controlContainer)}else if(e instanceof HTMLElement)e.appendChild(this._controlContainer);else throw Error(`容器必须是字符串选择器或 HTML 元素`)}_setPointerEvents(e){this._controlContainer.style.pointerEvents=e,this._swiper.style.pointerEvents=e}_onDown=e=>{`touches`in e?(document.addEventListener(`touchmove`,this._onMove),document.addEventListener(`touchend`,this._onTouchEnd)):(document.addEventListener(`mousemove`,this._onMove),document.addEventListener(`mouseup`,this._onMouseUp))};_setPosition(e){let t=this._horizontal?this._bounds.height:this._bounds.width,n=Math.max(0,Math.min(e,t)),r=this._horizontal?`translate(0, ${n}px)`:`translate(${n}px, 0)`;this._controlContainer.style.transform=r,this._controlContainer.style.webkitTransform=r;let i=this._bounds.height,a,o;this._horizontal?(a=`rect(0, 999em, ${n}px, 0)`,o=`rect(${n}px, 999em, ${i}px, 0)`):(a=`rect(0, ${n}px, ${i}px, 0)`,o=`rect(0, 999em, ${i}px, ${n}px)`),this._mapA.getContainer().style.clip=a,this._mapB.getContainer().style.clip=o,this.currentPosition=n}_onMove=e=>{this.options.mousemove&&this._setPointerEvents(`none`),this._horizontal?this._setPosition(this._getY(e)):this._setPosition(this._getX(e))};_onMouseUp=()=>{document.removeEventListener(`mousemove`,this._onMove),document.removeEventListener(`mouseup`,this._onMouseUp),this._emitSlideEnd()};_onTouchEnd=()=>{document.removeEventListener(`touchmove`,this._onMove),document.removeEventListener(`touchend`,this._onTouchEnd),this._emitSlideEnd()};_emitSlideEnd(){this._eventTarget.dispatchEvent(new CustomEvent(`slideend`,{detail:{currentPosition:this.currentPosition}}))}_getX(e){let t=(`touches`in e?e.touches[0]:e).clientX-this._bounds.left;return Math.max(0,Math.min(t,this._bounds.width))}_getY(e){let t=(`touches`in e?e.touches[0]:e).clientY-this._bounds.top;return Math.max(0,Math.min(t,this._bounds.height))}setSlider(e){this._setPosition(e)}on(e,t){this._eventTarget.addEventListener(e,e=>{let n=e.detail;t(n)})}off(e,t){this._eventTarget.removeEventListener(e,t)}remove(){this._clearSync(),this._mapB.off(`resize`,this._onResize),[this._mapA,this._mapB].forEach(e=>{let t=e.getContainer();t.style.clip=``,t.removeEventListener(`mousemove`,this._onMove)}),this._swiper.removeEventListener(`mousedown`,this._onDown),this._swiper.removeEventListener(`touchstart`,this._onDown),this._controlContainer.remove()}};window.maplibregl&&(window.maplibregl.Compare=Z);var le=(0,t.memo)(e=>{let{title:r,open:a=!1,maskClosable:o=!0,mask:s,width:c=520,footer:l,onCancel:u,destroyOnHidden:d=!1,className:f,style:p,children:m,centered:h=!1}=e,g=s?.closable===void 0?o:s.closable,[_,v]=(0,t.useState)(a);(0,t.useEffect)(()=>{if(a)v(!0),document.body.style.overflow=`hidden`;else if(document.body.style.overflow=``,d){let e=setTimeout(()=>{v(!1)},200);return()=>clearTimeout(e)}},[a,d]),(0,t.useEffect)(()=>()=>{document.body.style.overflow=``},[]);let y=(0,t.useCallback)(e=>{e.target===e.currentTarget&&g&&u?.()},[g,u]),b=(0,t.useCallback)(e=>{e.stopPropagation(),u?.()},[u]);return _?(0,i.createPortal)((0,n.jsxs)(`div`,{className:`qm-modal-wrapper ${a?`qm-modal-open`:``} ${h?`qm-modal-centered`:``}`,children:[(0,n.jsx)(`div`,{className:`qm-modal-mask ${a?`qm-modal-mask-enter`:`qm-modal-mask-leave`}`}),(0,n.jsx)(`div`,{className:`qm-modal-container`,onClick:y,children:(0,n.jsxs)(`div`,{className:`qm-modal ${f||``} ${a?`qm-modal-enter`:`qm-modal-leave`}`,style:{width:typeof c==`number`?`${c}px`:c,...p},onClick:e=>e.stopPropagation(),children:[r&&(0,n.jsxs)(`div`,{className:`qm-modal-header`,children:[(0,n.jsx)(`div`,{className:`qm-modal-title`,children:r}),(0,n.jsx)(`button`,{type:`button`,className:`qm-modal-close`,onClick:b,"aria-label":`关闭`,children:(0,n.jsx)(`span`,{className:`qm-modal-close-x`,children:`×`})})]}),(0,n.jsx)(`div`,{className:`qm-modal-body`,children:m}),l!==null&&(0,n.jsx)(`div`,{className:`qm-modal-footer`,children:l})]})})]}),document.body):null}),ue=(0,t.memo)(e=>{let{map:r}=O(),[i,a]=(0,t.useState)(!1),[o,s]=(0,t.useState)(null),[c,l]=(0,t.useState)(null),u=(0,t.useCallback)(e=>{a(e)},[]);return(0,t.useEffect)(()=>{if(o&&c){let e=document.getElementById(`swipeContainer`);e&&(new Z(o,c,e,{mousemove:!1,orientation:`vertical`}),o.setCenter(r.getCenter()),o.setZoom(r.getZoom()),o.setBearing(r.getBearing()),c.setPitch(r.getPitch()))}},[o,c]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(g,{name:`卷帘对比`,position:{...e.position},icon:h.Swipe,openHandle:u,children:(0,n.jsx)(n.Fragment,{})}),(0,n.jsx)(le,{title:`卷帘对比`,mask:{closable:!1},open:i,width:1e3,footer:null,onCancel:()=>a(!1),destroyOnHidden:!0,children:(0,n.jsxs)(`div`,{id:`swipeContainer`,className:`maplibregl-swipe`,children:[(0,n.jsx)(A,{mapOptions:{...r.options,id:`swipeBeforeMap`},mapLayerSettting:r.mapLayerSetting,onMapLoad:e=>s(e),className:`swipe-map-container`,children:(0,n.jsx)(I,{position:{top:10,left:10}})}),(0,n.jsx)(A,{mapOptions:{...r.options,id:`swipeAfterMap`},mapLayerSettting:r.mapLayerSetting,onMapLoad:e=>l(e),className:`swipe-map-container`,children:(0,n.jsx)(I,{position:{top:10,right:10}})})]})})]})}),Q={Point:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAARxJREFUWEft1LEuREEYxfHf9jRLIRIqnUSpoOEFREUh3kFBo6LYKEj0StEp8ARUEvUmOg2NSHT07pW73XK/mZBtZto5c87/npn7dYx4dUacrwCUBkoDpYHcBiYwjTG84g2fOUMtB+AYu0PC9nGUCpEK8IyZX0IOq72DFIgUgFusBMw3cBnQfUuiAOu4ippivLqmj4g+ClDfby9i2Gjm8BTRRwFusBYxbDTLuI/oowCn2IkYNpoF9CP6KMA2ziOGjWYS7xF9FK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yEEqBW50+g3dyifzGlnD8S4H8a/N0aLAAAAABJRU5ErkJggg==`,Rectangle:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAASxJREFUWEft16FKBWEQBeDvvodBRCw+gFWbgtVkEkWLil6wGbSLgiZBxKDFajB6owgGwSQ3GMTmMyhz3YVluRdW+BcM/4FlYXf2zPnPzMJMxy92cYx7POGgeJ76dooFfOEGZx1sIV5UsYKrxNmH5emGgEfMJE7WmC4EvGK69sUbPhuzNAscR1xV9EJA1D56oIo59JrxNo5axnUt+jAEBMr6vGO/aJDGzH8InMU5pjDos1JAcHwXp47Tt4kHhJBB7iwgO5AdyA5kB7ID2YHsQHbg3ziwXgyLMaYdYa+loXAztqGCe7vcjG6xVEvYxUliEYu4q3EOVrOYhuv4QD+xgDFM1jj7owQkzj2S7jkEDCvBKi4Tq4gyR64qNsq/YA2xOgUuWtyMQsQ8JrCDlx+OVWdvFenv8gAAAABJRU5ErkJggg==`,Polygon:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAxVJREFUWEe1133InnMUB/DPKCQS87ZQtrJ5yT8LUShaJKHWzMSaWqkt07LyEjEvQykrL2WRFautoZBt3hoRhkRqjLyUKMuyGLHWan3X73q6unff7t+953Lq6um5nt855/s7z/ec870mqLfDcBeuwd94E7fUu/c/OWGEAIuxvOf8Ejw6Qox9jo4C4HtM6ZPsM/Q+/TAdWfx/xtbmwCgANuP0ytt+hE3IzzznYW3L9znMy++jAHgIt/cAeAw7cApOKwAPrAR5L5bWAjgKH+DUEjzVGETCizEV03AGzsTxfUC9jstqATyM2/Aqrqq8YXPsEPzTxyfkXVID4AK8iwNKmbeMCCDHV+DGlt83mImvagC8XG79CG7dj+SNy7VYiYNxOdbXkHA+nsFfCA92jQNAXH/EyTgRvwwDkJJ/WYi0AE+NM3ncPywteQ4+HQbgAdyJzzG9g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24kSaIkRJEhM1cyJA83JMKD5AUPvv9tfVpOe5999j3XkVX7tPfZa/h/3/p/a61dxT+Wqn8cn/8SwAhgHDAW6Ap0A9oDH+y6C5wHrgNfsnY4zw6MBhYD07Kc2vu3wD5gP/A9zaYUAG3NycIUJ2+A98AA24lCtYfAVuBkkn0WgB7AYdvyaH8BOAe8ABqBT85xf2CgXesLAq4EthWCKAagD3AGqDWjp8B24EiJKRBPpD/Y6eu/S96+GIBjwGwXfCbwrMTgXm15SM0O98cw4FF8TgMgsok8ktfA+BYGj3GWArvt4SowphDAhsDwz8ABoNqC9TWlRcDBFqy80OQKoJMk2Rh+FLO5EOkmEmY60AY4YYriwNRWCC4XQwGdiCjiWJMAiBgX3QuRbK49a6s6hDQsAI6nHaUcAP1i64GGyAEdtfnmSKnoEgj4ErjtwLwDeuYIlqQ6yxaidw1AfQQwCLgGdHJWX4GO7vl33soAoRrxxOzvh3pS50/BWmBTgnOxVpXMp6kMDHwL9aEdoAra2wPQ6i8Dw837j1DDVwcO7CwnWoLtPUANTf2hurAOzLPcnALWAc9bObjcaeW97NjXJBWiOcDRvxBYLrsDIrNEXKjNakatjWNCSPFZX2MqDWCFNShhUHneW0kAKvF3XHdUZWysJIBloa7ssu0XyWfovlIAaoCPjlCjbGbMBKDuVQe8Clt3ugxGqurF+rIFWBN9Ze2A5sBDpqwxbDNwKweQPcASp38zFLuR3j4LgAZNjWJRfhoIHaUHRYBMsRY/xOk0AWrBf0gWAClr0NQ0o6nIixgtIBpKdamLTgrj1uQwN8ZhJuo3d74kwKUAiHarAOUvj2jV6qICkCh5AMhBv7D1E+0Sk9PkBqAvJI14ApEqeQF4R/okU447u+uxDTH+W6HojpUDIE8qUnV/AUEbfiHgdnTrAAAAAElFTkSuQmCC`},$=[{id:`point`,title:`绘制点`,mode:`draw_point`,icon:Q.Point},{id:`line`,title:`绘制线`,mode:`draw_line_string`,icon:Q.Line},{id:`polygon`,title:`绘制面`,mode:`draw_polygon`,icon:Q.Polygon},{id:`reset`,title:`清除选中/所有`,mode:`simple_select`,icon:Q.Reset}],de=[{id:`gl-draw-line`,type:`line`,filter:[`all`,[`==`,`$type`,`LineString`]],layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-color":`#D20C0C`,"line-dasharray":[.2,2],"line-width":2}},{id:`gl-draw-polygon-fill`,type:`fill`,filter:[`all`,[`==`,`$type`,`Polygon`]],paint:{"fill-color":`#D20C0C`,"fill-outline-color":`#D20C0C`,"fill-opacity":.3}},{id:`gl-draw-polygon-midpoint`,type:`circle`,filter:[`all`,[`==`,`$type`,`Point`],[`==`,`meta`,`midpoint`]],paint:{"circle-radius":5,"circle-color":`#fbb03b`}},{id:`gl-draw-polygon-stroke-active`,type:`line`,filter:[`all`,[`==`,`$type`,`Polygon`]],layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-color":`#D20C0C`,"line-dasharray":[.3,3],"line-width":3}},{id:`gl-draw-polygon-and-line-vertex-halo-active`,type:`circle`,filter:[`all`,[`==`,`meta`,`vertex`],[`==`,`$type`,`Point`]],paint:{"circle-radius":5,"circle-color":`#FFF`}},{id:`gl-draw-polygon-and-line-vertex-active`,type:`circle`,filter:[`all`,[`==`,`meta`,`vertex`],[`==`,`$type`,`Point`]],paint:{"circle-radius":3,"circle-color":`#D20C0C`}},{id:`gl-draw-point-point-stroke-active`,type:`circle`,filter:[`all`,[`==`,`$type`,`Point`],[`==`,`meta`,`feature`],[`==`,`active`,`true`]],paint:{"circle-radius":8,"circle-color":`#FFF`}},{id:`gl-draw-point-active`,type:`circle`,filter:[`all`,[`==`,`$type`,`Point`],[`==`,`meta`,`feature`],[`==`,`active`,`true`]],paint:{"circle-radius":6,"circle-color":`#D20C0C`}},{id:`gl-draw-point-point-stroke-inactive`,type:`circle`,filter:[`all`,[`==`,`$type`,`Point`],[`==`,`meta`,`feature`],[`==`,`active`,`false`]],paint:{"circle-radius":8,"circle-color":`#FFF`}},{id:`gl-draw-point-inactive`,type:`circle`,filter:[`all`,[`==`,`$type`,`Point`],[`==`,`meta`,`feature`],[`==`,`active`,`false`]],paint:{"circle-radius":6,"circle-color":`#D20C0C`}}],fe=(0,t.memo)(e=>{let{position:r,onDraw:i,initFeature:s,modes:c}=e,l=c?$.filter(e=>c.includes(e.mode)||e.id===`reset`):$,{map:u}=O(),d=(0,t.useRef)(null);(0,t.useEffect)(()=>{s&&f(s)},[s]);let f=e=>{if(u&&e.features&&d.current){let t=x(e.features[0]);t&&u.fitBounds(t,{maxZoom:16});let n=d.current.add(e);d.current.changeMode(`simple_select`,{featureIds:n})}},p=(e,t)=>{if(!d.current||!u)return;t===`reset`&&d.current.deleteAll(),d.current.changeMode(e);let n=u.getCanvas();e===`simple_select`?n.style.cursor=``:n.style.cursor=`crosshair`},m=()=>{if(!d.current)return;let e=d.current.getAll();if(e&&e.features.length>0){let t=0;e.features.forEach(e=>{(e.geometry.type===`Polygon`||e.geometry.type===`MultiPolygon`)&&(t+=(0,o.default)(e))}),i({data:e,area:t})}};return(0,t.useEffect)(()=>(u&&!d.current&&(d.current=new a.default({displayControlsDefault:!1,styles:de,defaultMode:`simple_select`}),u.addControl(d.current,`bottom-left`),u.on(`draw.create`,m),u.on(`draw.delete`,m),u.on(`draw.update`,m),u.on(`draw.modechange`,e=>{let t=u.getCanvas();e.mode===`simple_select`?t.style.cursor=``:t.style.cursor=`crosshair`})),()=>{}),[]),(0,n.jsx)(`div`,{className:`mapboxgl-draw`,style:{...r},children:(0,n.jsx)(`div`,{className:`mapboxgl-draw-bar`,children:(0,n.jsx)(`div`,{children:l.map(e=>(0,n.jsx)(`div`,{title:e.title,className:`mapboxgl-draw-bar-button`,style:{backgroundImage:`url(${e.icon})`},onClick:()=>p(e.mode,e.id)},e.id))})})})});e.BaseLayer=S,e.BaseWidget=g,e.Draw=fe,e.LayerGroupWrapper=w,e.LayerList=I,e.LayerWrapper=C,e.Legend=L,e.MapContext=D,e.MapWidget=A,e.MapWrapper=E,e.Print=oe,e.Swipe=ue,e.useMap=O});
@@ -0,0 +1,36 @@
1
+ import { LngLatBounds } from 'maplibre-gl';
2
+ /**
3
+ * 浅比较
4
+ * @param obj1
5
+ * @param obj2
6
+ * @returns ture or false
7
+ */
8
+ declare const shollawEqual: (obj1: any, obj2: any) => boolean;
9
+ export declare function deepClone<T>(target: T, cache?: WeakMap<object, any>): T;
10
+ /**
11
+ * 防抖
12
+ * @param func
13
+ * @param delay
14
+ */
15
+ declare const debounce: <T extends object>(func: Function, delay: number) => (args: T) => void;
16
+ /**
17
+ * 节流
18
+ * @param func
19
+ * @param delay
20
+ */
21
+ declare const throttle: <T extends object>(func: Function, delay: number) => (args: T) => void;
22
+ /**
23
+ * 转换树形数据为数组
24
+ * @param {*} list
25
+ * @param {*} tree
26
+ */
27
+ declare const transTreeToArr: (list: any[], tree: any) => void;
28
+ declare const getFeatureBoundingBox: (feature: any) => LngLatBounds;
29
+ declare const unique: (arr: any[], uniId: string) => any[];
30
+ /**
31
+ * 将multipolygon类型几何拆分为多个独立polygon,并保留原有polygon
32
+ * @param feats feature[]
33
+ * @returns {{}}
34
+ */
35
+ declare const modifyMultiPolygon: (feats: any[]) => any[];
36
+ export { shollawEqual, debounce, throttle, transTreeToArr, getFeatureBoundingBox, unique, modifyMultiPolygon, };
@@ -0,0 +1,24 @@
1
+ import { ReactNode } from 'react';
2
+ export interface TWidgetPosition {
3
+ top?: number;
4
+ bottom?: number;
5
+ left?: number;
6
+ right?: number;
7
+ }
8
+ export interface TWidgetOptions {
9
+ position: TWidgetPosition;
10
+ children: ReactNode;
11
+ name?: string;
12
+ icon: string;
13
+ width?: number;
14
+ height?: number;
15
+ openHandle?: (value: boolean) => void;
16
+ }
17
+ export declare const ControlICONS: {
18
+ Swipe: string;
19
+ Legend: string;
20
+ LayerList: string;
21
+ Print: string;
22
+ };
23
+ declare const _default: import('react').MemoExoticComponent<(props: TWidgetOptions) => import("react/jsx-runtime").JSX.Element>;
24
+ export default _default;
@@ -0,0 +1,57 @@
1
+ export type TDrawModeType = 'draw_point' | 'draw_line_string' | 'draw_polygon' | 'simple_select';
2
+ export type TDrawMode = {
3
+ id: string;
4
+ title: string;
5
+ mode: TDrawModeType;
6
+ icon: string;
7
+ };
8
+ export declare const drawToolList: TDrawMode[];
9
+ export declare const drawStyles: ({
10
+ id: string;
11
+ type: string;
12
+ filter: (string | string[])[];
13
+ layout: {
14
+ 'line-cap': string;
15
+ 'line-join': string;
16
+ };
17
+ paint: {
18
+ 'line-color': string;
19
+ 'line-dasharray': number[];
20
+ 'line-width': number;
21
+ 'fill-color'?: undefined;
22
+ 'fill-outline-color'?: undefined;
23
+ 'fill-opacity'?: undefined;
24
+ 'circle-radius'?: undefined;
25
+ 'circle-color'?: undefined;
26
+ };
27
+ } | {
28
+ id: string;
29
+ type: string;
30
+ filter: (string | string[])[];
31
+ paint: {
32
+ 'fill-color': string;
33
+ 'fill-outline-color': string;
34
+ 'fill-opacity': number;
35
+ 'line-color'?: undefined;
36
+ 'line-dasharray'?: undefined;
37
+ 'line-width'?: undefined;
38
+ 'circle-radius'?: undefined;
39
+ 'circle-color'?: undefined;
40
+ };
41
+ layout?: undefined;
42
+ } | {
43
+ id: string;
44
+ type: string;
45
+ filter: (string | string[])[];
46
+ paint: {
47
+ 'circle-radius': number;
48
+ 'circle-color': string;
49
+ 'line-color'?: undefined;
50
+ 'line-dasharray'?: undefined;
51
+ 'line-width'?: undefined;
52
+ 'fill-color'?: undefined;
53
+ 'fill-outline-color'?: undefined;
54
+ 'fill-opacity'?: undefined;
55
+ };
56
+ layout?: undefined;
57
+ })[];
@@ -0,0 +1,17 @@
1
+ import { TWidgetPosition } from '../BaseWidget';
2
+ import { TDrawModeType } from './constant';
3
+ import { FeatureCollection, Geometry, GeoJsonProperties } from 'geojson';
4
+ export type { TDrawModeType } from './constant';
5
+ export interface TDrawResult {
6
+ area: number;
7
+ data: FeatureCollection<Geometry, GeoJsonProperties>;
8
+ }
9
+ export interface TDrawControlProps {
10
+ detailSource?: any;
11
+ position: TWidgetPosition;
12
+ initFeature?: FeatureCollection;
13
+ modes?: TDrawModeType[];
14
+ onDraw: (drawResult: TDrawResult) => void;
15
+ }
16
+ declare const _default: import('react').MemoExoticComponent<(props: TDrawControlProps) => import("react/jsx-runtime").JSX.Element>;
17
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import { TWidgetPosition } from '../BaseWidget';
2
+ declare const _default: import('react').MemoExoticComponent<(props: {
3
+ position: TWidgetPosition;
4
+ }) => import("react/jsx-runtime").JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,16 @@
1
+ export interface DataNode {
2
+ title: React.ReactNode;
3
+ key: string;
4
+ children?: DataNode[];
5
+ selectable?: boolean;
6
+ disabled?: boolean;
7
+ }
8
+ export interface TreeProps {
9
+ treeData: DataNode[];
10
+ checkable?: boolean;
11
+ checkedKeys?: string[];
12
+ onCheck?: (checkedKeys: string[]) => void;
13
+ style?: React.CSSProperties;
14
+ }
15
+ declare const _default: import('react').MemoExoticComponent<(props: TreeProps) => import("react/jsx-runtime").JSX.Element>;
16
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import { TWidgetPosition } from '../BaseWidget';
2
+ declare const _default: import('react').MemoExoticComponent<(props: {
3
+ position: TWidgetPosition;
4
+ }) => import("react/jsx-runtime").JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,16 @@
1
+ import { MapOptions } from 'maplibre-gl';
2
+ import { default as React } from 'react';
3
+ import { default as MapWrapper } from '../../maplibregl/MapWrapper';
4
+ import { TMapLayerSettting } from '../../maplibregl/typings/TLayerOptions';
5
+ export interface TMapProps {
6
+ mapOptions: MapOptions & {
7
+ id: string;
8
+ };
9
+ mapLayerSettting: TMapLayerSettting;
10
+ children?: React.ReactNode;
11
+ onMapLoad?: (map: MapWrapper) => void;
12
+ className?: string;
13
+ }
14
+ declare function MapWidget(props: TMapProps): import("react/jsx-runtime").JSX.Element;
15
+ declare const _default: React.MemoExoticComponent<typeof MapWidget>;
16
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import { ReactElement } from 'react';
2
+ interface TPopupPanel {
3
+ vector?: {
4
+ id: string;
5
+ title: string;
6
+ template: ReactElement;
7
+ }[];
8
+ }
9
+ declare const _default: import('react').MemoExoticComponent<(props: TPopupPanel) => import("react/jsx-runtime").JSX.Element>;
10
+ export default _default;
@@ -0,0 +1,16 @@
1
+ import { Popup, LngLatLike, PopupOptions } from 'maplibre-gl';
2
+ import { ReactNode } from 'react';
3
+ export type PopupEvent = {
4
+ type: 'open' | 'close';
5
+ target: Popup;
6
+ };
7
+ export type TPopupWrapper = PopupOptions & {
8
+ children: ReactNode;
9
+ lngLat: LngLatLike;
10
+ enableDrag?: boolean;
11
+ title: string;
12
+ onOpen?: (e: PopupEvent) => void;
13
+ onClose?: (e: PopupEvent) => void;
14
+ };
15
+ declare const _default: import('react').MemoExoticComponent<(props: TPopupWrapper) => import('react').ReactPortal>;
16
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { Map } from 'maplibre-gl';
2
+ export default class CrosshairManager {
3
+ private map;
4
+ private svgCanvas;
5
+ constructor(map: Map | null);
6
+ create(): void;
7
+ destroy(): void;
8
+ }
@@ -0,0 +1,4 @@
1
+ export default class ImageExporter {
2
+ toPNG(canvas: HTMLCanvasElement, fileName: string): void;
3
+ toJPEG(canvas: HTMLCanvasElement, fileName: string, quality?: number): void;
4
+ }
@@ -0,0 +1,26 @@
1
+ import { Format as FormatType, DPI as DPIType, Unit as UnitType, MarkerOptions } from './types';
2
+ import { Map } from 'maplibre-gl';
3
+ import { NorthIconOptions } from './NorthIconManager';
4
+ export interface MapGeneratorOptions {
5
+ jpegQuality?: number;
6
+ northIcon?: boolean;
7
+ northIconOptions?: Partial<NorthIconOptions>;
8
+ markerOptions?: Partial<MarkerOptions>;
9
+ }
10
+ export default class MapGenerator {
11
+ private map;
12
+ private width;
13
+ private height;
14
+ private dpi;
15
+ private format;
16
+ private unit;
17
+ private jpegQuality;
18
+ private northIcon;
19
+ private northIconOptions;
20
+ private markerOptions;
21
+ constructor(map: Map, size: [number, number], dpi: DPIType, format: FormatType, unit?: UnitType, options?: MapGeneratorOptions);
22
+ generate(onComplete?: () => void): void;
23
+ private toPixels;
24
+ private showLoading;
25
+ private hideLoading;
26
+ }
@@ -0,0 +1,22 @@
1
+ import { Map as MaplibreMap } from 'maplibre-gl';
2
+ import { CirclePaint } from './types';
3
+ export interface MarkerOptions {
4
+ markerClassName?: string;
5
+ markerCirclePaint?: CirclePaint;
6
+ }
7
+ export default class MarkersManager {
8
+ private sourceMap;
9
+ private renderMap;
10
+ private markerClassName;
11
+ private markerCirclePaint;
12
+ constructor(sourceMap: MaplibreMap, renderMap: MaplibreMap, options?: MarkerOptions);
13
+ /**
14
+ * 获取源地图上的所有 Marker 元素
15
+ */
16
+ private getMarkers;
17
+ /**
18
+ * 将源地图上的 Marker 渲染到导出地图上
19
+ * @returns 返回是否有 Marker 被渲染
20
+ */
21
+ renderMarkers(): boolean;
22
+ }
@@ -0,0 +1,44 @@
1
+ import { Map } from 'maplibre-gl';
2
+ export interface NorthIconOptions {
3
+ image: string;
4
+ imageName?: string;
5
+ imageSizeFraction?: number;
6
+ visibility?: 'visible' | 'none';
7
+ position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
8
+ }
9
+ export default class NorthIconManager {
10
+ private options;
11
+ constructor(options?: Partial<NorthIconOptions>);
12
+ /**
13
+ * 添加指北针到地图
14
+ * @param map MapLibre 地图实例
15
+ * @param mapWidth 地图宽度(用于判断是否在横向地图上隐藏指北针)
16
+ * @param mapHeight 地图高度(用于判断是否在横向地图上隐藏指北针)
17
+ */
18
+ addToMap(map: Map, mapWidth: number, mapHeight: number): Promise<void>;
19
+ /**
20
+ * 添加指北针图片到地图
21
+ * @param map MapLibre 地图实例
22
+ */
23
+ private addNorthIconImage;
24
+ /**
25
+ * 根据地图宽度计算图标大小
26
+ * @param map MapLibre 地图实例
27
+ * @param fraction 图标大小比例
28
+ * @returns 图标宽度(像素)
29
+ */
30
+ private getIconWidth;
31
+ /**
32
+ * 根据位置和偏移量获取像素坐标
33
+ * @param map MapLibre 地图实例
34
+ * @param position 位置
35
+ * @param offset 偏移量(像素)
36
+ * @returns 像素坐标 [width, height]
37
+ */
38
+ private getElementPosition;
39
+ /**
40
+ * 更新指北针选项
41
+ * @param options 新的指北针选项
42
+ */
43
+ updateOptions(options: Partial<NorthIconOptions>): void;
44
+ }
@@ -0,0 +1,10 @@
1
+ import { Unit } from './types';
2
+ export default class PDFGenerator {
3
+ private width;
4
+ private height;
5
+ private unit;
6
+ constructor(width: number, height: number, unit: Unit);
7
+ generate(canvas: HTMLCanvasElement, fileName: string): void;
8
+ private buildPDF;
9
+ private createPDFStructure;
10
+ }
@@ -0,0 +1,12 @@
1
+ import { Map } from 'maplibre-gl';
2
+ import { Unit } from './types';
3
+ export default class PrintableAreaManager {
4
+ private map;
5
+ private svgCanvas;
6
+ private path;
7
+ constructor(map: Map | null);
8
+ updateArea(width: number, height: number, unit?: Unit): void;
9
+ create(): void;
10
+ destroy(): void;
11
+ private toPixels;
12
+ }
@@ -0,0 +1,3 @@
1
+ export default class SVGExporter {
2
+ toSVG(canvas: HTMLCanvasElement, fileName: string, width: number, height: number, unit: string, dpi: number): void;
3
+ }
@@ -0,0 +1,58 @@
1
+ export type CirclePaint = {
2
+ 'circle-radius': number;
3
+ 'circle-color': string;
4
+ 'circle-stroke-width': number;
5
+ 'circle-stroke-color': string;
6
+ };
7
+ export declare const Format: {
8
+ readonly JPEG: "jpg";
9
+ readonly PNG: "png";
10
+ readonly PDF: "pdf";
11
+ readonly SVG: "svg";
12
+ };
13
+ export type Format = (typeof Format)[keyof typeof Format];
14
+ export declare const Unit: {
15
+ readonly mm: "mm";
16
+ };
17
+ export type Unit = (typeof Unit)[keyof typeof Unit];
18
+ export declare const Size: {
19
+ readonly A2: readonly [594, 420];
20
+ readonly A3: readonly [420, 297];
21
+ readonly A4: readonly [297, 210];
22
+ readonly A5: readonly [210, 148];
23
+ readonly A6: readonly [148, 105];
24
+ readonly B2: readonly [707, 500];
25
+ readonly B3: readonly [500, 353];
26
+ readonly B4: readonly [353, 250];
27
+ readonly B5: readonly [250, 176];
28
+ readonly B6: readonly [176, 125];
29
+ readonly Letter: readonly [279, 216];
30
+ };
31
+ export type Size = (typeof Size)[keyof typeof Size];
32
+ export declare const PageOrientation: {
33
+ readonly 横向: "landscape";
34
+ readonly 纵向: "portrait";
35
+ };
36
+ export type PageOrientation = (typeof PageOrientation)[keyof typeof PageOrientation];
37
+ export declare const DPI: {
38
+ readonly 72: 72;
39
+ readonly 96: 96;
40
+ readonly 200: 200;
41
+ readonly 300: 300;
42
+ readonly 400: 400;
43
+ };
44
+ export type DPI = (typeof DPI)[keyof typeof DPI];
45
+ export type MarkerOptions = {
46
+ markerClassName?: string;
47
+ markerCirclePaint?: CirclePaint;
48
+ };
49
+ export type ExportOptions = {
50
+ PageSize: Size;
51
+ PageOrientation: PageOrientation;
52
+ Format: Format;
53
+ DPI: DPI;
54
+ JPEGQuality?: number;
55
+ Crosshair?: boolean;
56
+ PrintableArea?: boolean;
57
+ MarkerOptions?: MarkerOptions;
58
+ };
@@ -0,0 +1,5 @@
1
+ import { TWidgetPosition } from '../BaseWidget';
2
+ declare const _default: import('react').MemoExoticComponent<(props: {
3
+ position: TWidgetPosition;
4
+ }) => import("react/jsx-runtime").JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,43 @@
1
+ import { Map } from 'maplibre-gl';
2
+ export interface CompareOptions {
3
+ orientation?: 'vertical' | 'horizontal';
4
+ mousemove?: boolean;
5
+ }
6
+ export declare class Compare {
7
+ readonly options: Required<CompareOptions>;
8
+ private readonly _mapA;
9
+ private readonly _mapB;
10
+ private readonly _horizontal;
11
+ private _bounds;
12
+ currentPosition: number;
13
+ private readonly _swiper;
14
+ private readonly _controlContainer;
15
+ private readonly _clearSync;
16
+ private _onResize;
17
+ private readonly _eventTarget;
18
+ constructor(a: Map, b: Map, container: string | HTMLElement, options?: CompareOptions);
19
+ private _mountContainer;
20
+ private _setPointerEvents;
21
+ private _onDown;
22
+ private _setPosition;
23
+ private _onMove;
24
+ private _onMouseUp;
25
+ private _onTouchEnd;
26
+ private _emitSlideEnd;
27
+ private _getX;
28
+ private _getY;
29
+ setSlider(x: number): void;
30
+ on(type: 'slideend', callback: (data: {
31
+ currentPosition: number;
32
+ }) => void): void;
33
+ off(type: 'slideend', callback: (data: {
34
+ currentPosition: number;
35
+ }) => void): void;
36
+ remove(): void;
37
+ }
38
+ declare global {
39
+ interface Window {
40
+ maplibregl: any;
41
+ }
42
+ }
43
+ export default Compare;
@@ -0,0 +1,6 @@
1
+ import { Map } from 'maplibre-gl';
2
+ /**
3
+ * 同步多个地图的视角
4
+ */
5
+ export declare function syncMaps(...maps: Map[] | [Map[]]): () => void;
6
+ export default syncMaps;
@@ -0,0 +1,5 @@
1
+ import { TWidgetPosition } from '../BaseWidget';
2
+ declare const _default: import('react').MemoExoticComponent<(props: {
3
+ position: TWidgetPosition;
4
+ }) => import("react/jsx-runtime").JSX.Element>;
5
+ export default _default;