@xingm/vmap-cesium-toolbar 0.0.1-beta.2 → 0.0.1-beta.4

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.
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(d,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("cesium")):typeof define=="function"&&define.amd?define(["exports","cesium"],u):(d=typeof globalThis<"u"?globalThis:d||self,u(d.VMapCesiumToolbar={},d.Cesium))})(this,(function(d,u){"use strict";function E(h){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const t in h)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(h,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>h[t]})}}return e.default=h,Object.freeze(e)}const n=E(u);class p{viewer;scene;entities;frustumPrimitives=[];drawMode=null;isDrawing=!1;tempPositions=[];tempEntities=[];finishedEntities=[];screenSpaceEventHandler=null;onDrawStartCallback=null;onDrawEndCallback=null;onEntityRemovedCallback=null;constructor(e){if(!e||!(e instanceof n.Viewer))throw new Error("Invalid Cesium Viewer instance provided.");this.viewer=e,this.scene=e.scene,this.entities=e.entities,this.scene.globe.depthTestAgainstTerrain=!0}clearFrustum(){this.frustumPrimitives.forEach(e=>{e&&!e.isDestroyed()&&this.viewer.scene.primitives.remove(e)}),this.frustumPrimitives=[],this.screenSpaceEventHandler&&(this.screenSpaceEventHandler.destroy(),this.screenSpaceEventHandler=null)}drawFrustum(e={}){try{this.clearFrustum();const t=Math.max(1,Math.min(179,e.fov||60)),i=Math.max(.1,e.aspectRatio||1),r=Math.max(.1,e.near||1),s=Math.max(r+1,e.far||1e3),o=e.position||this.viewer.camera.positionWC,a=e.orientation||n.Quaternion.fromRotationMatrix(n.Matrix4.getRotation(this.viewer.camera.transform,new n.Matrix3)),l=new n.PerspectiveFrustum({fov:n.Math.toRadians(t),aspectRatio:i,near:r,far:s}),c=new n.FrustumGeometry({frustum:l,origin:o,orientation:a,vertexFormat:n.VertexFormat.POSITION_ONLY}),m=new n.GeometryInstance({geometry:c,attributes:{color:n.ColorGeometryInstanceAttribute.fromColor(e.fillColor||new n.Color(1,0,0,.3))}}),g=new n.Primitive({geometryInstances:m,appearance:new n.PerInstanceColorAppearance({closed:!0,flat:!0})}),y=new n.FrustumOutlineGeometry({frustum:l,origin:o,orientation:a}),x=new n.GeometryInstance({geometry:y,attributes:{color:n.ColorGeometryInstanceAttribute.fromColor(e.outlineColor||new n.Color(1,1,1,1))}}),b=new n.Primitive({geometryInstances:x,appearance:new n.PerInstanceColorAppearance({closed:!0,flat:!0})});this.viewer.scene.primitives.add(g),this.viewer.scene.primitives.add(b),this.frustumPrimitives.push(g,b),e.onRightClick&&this.screenSpaceEventHandler&&this.screenSpaceEventHandler.setInputAction(I=>{I.position&&e.onRightClick&&e.onRightClick(o)},n.ScreenSpaceEventType.RIGHT_CLICK)}catch(t){console.error("绘制视锥体时发生错误:",t),this.clearFrustum()}}startDrawingLine(){this.startDrawing("line")}startDrawingPolygon(){this.startDrawing("polygon")}startDrawingRectangle(){this.startDrawing("rectangle")}startDrawing(e){this.endDrawingInternal(!1),this.drawMode=e,this.isDrawing=!0,this.tempPositions=[],this.tempEntities=[],this.activateDrawingHandlers(),this.onDrawStartCallback&&this.onDrawStartCallback()}activateDrawingHandlers(){this.deactivateDrawingHandlers(),this.screenSpaceEventHandler=new n.ScreenSpaceEventHandler(this.scene.canvas),this.screenSpaceEventHandler.setInputAction(t=>{if(!this.isDrawing)return;const i=this.pickGlobePosition(t.position);i&&this.addPoint(i)},n.ScreenSpaceEventType.LEFT_CLICK),this.screenSpaceEventHandler.setInputAction(()=>{!this.isDrawing||this.tempPositions.length===0||this.removeLastPoint()},n.ScreenSpaceEventType.RIGHT_CLICK),this.screenSpaceEventHandler.setInputAction(t=>{if(!this.isDrawing||this.tempPositions.length===0)return;const i=this.pickGlobePosition(t.endPosition);i&&this.updatePreview(i)},n.ScreenSpaceEventType.MOUSE_MOVE);const e=this.viewer.cesiumWidget.screenSpaceEventHandler.getInputAction(n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);this.viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.screenSpaceEventHandler.setInputAction(t=>{this.isDrawing&&(this.finishDrawing(),this.viewer.cesiumWidget.screenSpaceEventHandler.setInputAction(e,n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK))},n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}pickGlobePosition(e){const t=this.viewer.camera.getPickRay(e);if(t){const r=this.scene.globe.pick(t,this.scene);if(n.defined(r))return r}return this.viewer.camera.pickEllipsoid(e,this.scene.globe.ellipsoid)??null}addPoint(e){this.tempPositions.push(e.clone());const t=this.entities.add({position:e.clone(),point:{pixelSize:5,color:n.Color.RED,outlineColor:n.Color.WHITE,outlineWidth:2,heightReference:n.HeightReference.CLAMP_TO_GROUND}});this.tempEntities.push(t),this.updateDrawingEntity()}removeLastPoint(){if(this.tempPositions.length>0){this.tempPositions.pop();const e=this.tempEntities.pop();e&&this.entities.remove(e);const t=this.tempEntities.pop();t&&this.entities.remove(t),this.updateDrawingEntity()}}updatePreview(e){this.updateDrawingEntity(e)}updateDrawingEntity(e){this.tempEntities.forEach(r=>{r&&(r.polyline||r.polygon||r.label)&&this.entities.remove(r)}),this.tempEntities=[];const t=[...this.tempPositions];if(e&&t.push(e),t.length<2)return;let i;if(this.drawMode==="line"){i=this.entities.add({polyline:{positions:t,width:3,material:n.Color.YELLOW,clampToGround:!0}}),this.tempEntities.push(i);for(let r=0;r<t.length-1;r++){const s=t[r],o=t[r+1],a=n.Cartesian3.distance(s,o),l=n.Cartesian3.midpoint(s,o,new n.Cartesian3),c=this.entities.add({position:l,label:{text:`${a.toFixed(2)} m`,font:"12px sans-serif",fillColor:n.Color.CYAN,outlineColor:n.Color.BLACK,outlineWidth:1,style:n.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new n.Cartesian2(0,-10),heightReference:n.HeightReference.CLAMP_TO_GROUND}});this.tempEntities.push(c)}if(t.length>1){let r=0;for(let o=1;o<t.length;o++)r+=n.Cartesian3.distance(t[o-1],t[o]);const s=this.entities.add({position:t[t.length-1],label:{text:`总长: ${r.toFixed(2)} m`,font:"14px sans-serif",fillColor:n.Color.WHITE,outlineColor:n.Color.BLACK,outlineWidth:2,style:n.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new n.Cartesian2(0,20),heightReference:n.HeightReference.CLAMP_TO_GROUND}});this.tempEntities.push(s)}}else if(this.drawMode==="polygon")i=this.entities.add({polygon:{hierarchy:new n.CallbackProperty(()=>new n.PolygonHierarchy(t),!1),material:n.Color.LIGHTGREEN.withAlpha(.3),outline:!0,outlineColor:n.Color.GREEN,outlineWidth:2,heightReference:n.HeightReference.CLAMP_TO_GROUND}});else if(this.drawMode==="rectangle"&&t.length>=2){const r=this.calculateRectangle(t[0],t[1]);i=this.entities.add({rectangle:{coordinates:r,material:n.Color.GREEN.withAlpha(.5),heightReference:n.HeightReference.CLAMP_TO_GROUND}})}i&&this.tempEntities.push(i)}finishDrawing(){if(this.tempPositions.length<(this.drawMode==="rectangle",2)){this.endDrawingInternal(!0);return}let e=null;const t=this.tempPositions.map(i=>i.clone());if(this.drawMode==="line"){e=this.entities.add({name:"绘制的线",polyline:{positions:t,width:3,material:n.Color.YELLOW,clampToGround:!0}});for(let i=0;i<t.length-1;i++){const r=t[i],s=t[i+1],o=n.Cartesian3.distance(r,s),a=n.Cartesian3.midpoint(r,s,new n.Cartesian3);this.entities.add({position:a,label:{text:`${o.toFixed(2)} m`,font:"12px sans-serif",fillColor:n.Color.CYAN,outlineColor:n.Color.BLACK,outlineWidth:1,style:n.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new n.Cartesian2(0,-10),heightReference:n.HeightReference.CLAMP_TO_GROUND}})}if(t.length>1){let i=0;for(let r=1;r<t.length;r++)i+=n.Cartesian3.distance(t[r-1],t[r]);this.entities.add({position:t[t.length-1],label:{text:`总长: ${i.toFixed(2)} m`,font:"14px sans-serif",fillColor:n.Color.WHITE,outlineColor:n.Color.BLACK,outlineWidth:2,style:n.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new n.Cartesian2(0,20),heightReference:n.HeightReference.CLAMP_TO_GROUND}})}}else if(this.drawMode==="polygon"){e=this.entities.add({name:"绘制的多边形区域",polygon:{hierarchy:new n.PolygonHierarchy(t),material:n.Color.LIGHTGREEN.withAlpha(.3),outline:!0,outlineColor:n.Color.GREEN,outlineWidth:2,heightReference:n.HeightReference.CLAMP_TO_GROUND}});const i=this.calculatePolygonArea(t);if(i>0){const r=this.calculatePolygonCenter(t);this.entities.add({position:r,label:{text:`面积: ${i.toFixed(2)} km²`,font:"14px sans-serif",fillColor:n.Color.WHITE,outlineColor:n.Color.BLACK,outlineWidth:2,style:n.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new n.Cartesian2(0,-20),heightReference:n.HeightReference.CLAMP_TO_GROUND}})}}else if(this.drawMode==="rectangle"&&t.length>=2){const i=this.calculateRectangle(t[0],t[1]);e=this.entities.add({name:"绘制的矩形",rectangle:{coordinates:i,material:n.Color.GREEN.withAlpha(.5),heightReference:n.HeightReference.CLAMP_TO_GROUND}});const r=this.calculateRectangleArea(i);if(r>0){const s=n.Rectangle.center(i);this.entities.add({position:n.Cartesian3.fromRadians(s.longitude,s.latitude),label:{text:`面积: ${r.toFixed(2)} km²`,font:"14px sans-serif",fillColor:n.Color.WHITE,outlineColor:n.Color.BLACK,outlineWidth:2,style:n.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new n.Cartesian2(0,-20),heightReference:n.HeightReference.CLAMP_TO_GROUND}})}}e&&this.finishedEntities.push(e),this.endDrawingInternal(!0),this.onDrawEndCallback&&this.onDrawEndCallback(e)}endDrawingInternal(e){this.tempEntities.forEach(t=>{this.entities.remove(t)}),this.tempEntities=[],this.tempPositions=[],e&&(this.drawMode=null,this.isDrawing=!1,this.deactivateDrawingHandlers())}endDrawing(){this.isDrawing?this.finishDrawing():this.endDrawingInternal(!0)}deactivateDrawingHandlers(){this.screenSpaceEventHandler&&(this.screenSpaceEventHandler.destroy(),this.screenSpaceEventHandler=null)}clearAll(){this.endDrawing(),this.finishedEntities.forEach(e=>{this.entities.remove(e)}),this.finishedEntities=[]}removeEntity(e){const t=this.finishedEntities.indexOf(e);t>-1&&(this.entities.remove(e),this.finishedEntities.splice(t,1),this.onEntityRemovedCallback&&this.onEntityRemovedCallback(e))}getFinishedEntities(){return[...this.finishedEntities]}calculateRectangle(e,t){const i=n.Cartographic.fromCartesian(e),r=n.Cartographic.fromCartesian(t),s=Math.min(i.longitude,r.longitude),o=Math.max(i.longitude,r.longitude),a=Math.min(i.latitude,r.latitude),l=Math.max(i.latitude,r.latitude);return new n.Rectangle(s,a,o,l)}calculateRectangleArea(e){const t=e.west,i=e.south,r=e.east,s=e.north,o=n.Cartesian3.distance(n.Cartesian3.fromRadians(t,i),n.Cartesian3.fromRadians(r,i)),a=n.Cartesian3.distance(n.Cartesian3.fromRadians(t,i),n.Cartesian3.fromRadians(t,s));return o*a/1e6}calculatePolygonArea(e){if(e.length<3)return 0;const t=this.scene.globe.ellipsoid;let i=0;const r=e.length;for(let s=0;s<r;s++){const o=t.cartesianToCartographic(e[s]),a=t.cartesianToCartographic(e[(s+1)%r]);i+=(a.longitude-o.longitude)*(2+Math.sin(o.latitude)+Math.sin(a.latitude))}return i=Math.abs(i*6378137*6378137/2),i/1e6}calculatePolygonCenter(e){if(e.length===0)return n.Cartesian3.ZERO;let t=0,i=0,r=0;for(let s=0;s<e.length;s++)t+=e[s].x,i+=e[s].y,r+=e[s].z;return new n.Cartesian3(t/e.length,i/e.length,r/e.length)}onDrawStart(e){this.onDrawStartCallback=e}onDrawEnd(e){this.onDrawEndCallback=e}onEntityRemoved(e){this.onEntityRemovedCallback=e}drawMonitoringCircle(e,t,i,r,s){const o=s?.borderColor||"#0062FF",a=s?.fillColor||"#0062FF",l=s?.borderWidth||2,c=s?.name||"监控区域";return this.entities.add({name:c,position:n.Cartesian3.fromDegrees(e,t,i),ellipse:{semiMajorAxis:r,semiMinorAxis:r,material:n.Color.fromCssColorString(a).withAlpha(.27),outline:!0,outlineColor:n.Color.fromCssColorString(o),outlineWidth:l,heightReference:n.HeightReference.CLAMP_TO_GROUND}})}drawVerticalLine(e,t,i,r){const s=r?.color||"#0062FF",o=r?.width||2;r?.dashPattern;const a=r?.name||"垂直线条",l=r?.groundHeight||0,c=n.Cartesian3.fromDegrees(e,t,l),m=n.Cartesian3.fromDegrees(e,t,i);return this.entities.add({name:a,polyline:{positions:[c,m],width:o,material:new n.PolylineDashMaterialProperty({color:n.Color.fromCssColorString(s)}),clampToGround:!1}})}destroy(){this.deactivateDrawingHandlers(),this.clearFrustum()}}window.DrawHelper=p;class f{viewer;drawHelper;container;toolbarElement;config;searchCallback;measurementCallback;zoomCallback;initialCenter;isFullscreen=!1;currentMapType="imagery";mapTypes=[{id:"normal",name:"天地图-普通",thumbnail:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjQwIiBoZWlnaHQ9IjQwIiBmaWxsPSIjZjBmMGYwIi8+CjxwYXRoIGQ9Ik0xMCAxMEgzMFYzMEgxMFYxMFoiIGZpbGw9IiNlMGUwZTAiLz4KPC9zdmc+",provider:new n.UrlTemplateImageryProvider({url:"https://t{s}.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}&tk=your_token",subdomains:["0","1","2","3","4","5","6","7"],minimumLevel:1,maximumLevel:18,credit:"© 天地图"})},{id:"3d",name:"天地图-三维",thumbnail:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjQwIiBoZWlnaHQ9IjQwIiBmaWxsPSIjZjBmMGYwIi8+CjxwYXRoIGQ9Ik0xMCAxMEgzMFYzMEgxMFYxMFoiIGZpbGw9IiNlMGUwZTAiLz4KPC9zdmc+",provider:new n.UrlTemplateImageryProvider({url:"https://t{s}.tianditu.gov.cn/ter_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ter&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}&tk=your_token",subdomains:["0","1","2","3","4","5","6","7"],minimumLevel:1,maximumLevel:18,credit:"© 天地图"})},{id:"imagery",name:"天地图-影像",thumbnail:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjQwIiBoZWlnaHQ9IjQwIiBmaWxsPSIjZjBmMGYwIi8+CjxwYXRoIGQ9Ik0xMCAxMEgzMFYzMEgxMFYxMFoiIGZpbGw9IiNlMGUwZTAiLz4KPC9zdmc+",provider:new n.UrlTemplateImageryProvider({url:"https://t{s}.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}&tk=your_token",subdomains:["0","1","2","3","4","5","6","7"],minimumLevel:1,maximumLevel:18,credit:"© 天地图"})},{id:"terrain",name:"天地图-地形",thumbnail:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjQwIiBoZWlnaHQ9IjQwIiBmaWxsPSIjZjBmMGYwIi8+CjxwYXRoIGQ9Ik0xMCAxMEgzMFYzMEgxMFYxMFoiIGZpbGw9IiNlMGUwZTAiLz4KPC9zdmc+",provider:new n.UrlTemplateImageryProvider({url:"https://t{s}.tianditu.gov.cn/ter_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ter&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}&tk=your_token",subdomains:["0","1","2","3","4","5","6","7"],minimumLevel:1,maximumLevel:18,credit:"© 天地图"})}];constructor(e,t,i={},r,s){this.viewer=e,this.container=t,this.config={position:"bottom-right",buttonSize:40,buttonSpacing:8,backgroundColor:"rgba(255, 255, 255, 0.9)",borderColor:"#e0e0e0",borderRadius:6,boxShadow:"0 2px 10px rgba(0, 0, 0, 0.1)",zIndex:1e3,...i},this.searchCallback=r?.search,this.measurementCallback=r?.measurement,this.zoomCallback=r?.zoom,this.initialCenter=s,this.drawHelper=new p(e),this.setupDrawHelperCallbacks(),this.createToolbar()}setInitialCenter(e){this.initialCenter=e}getInitialCenter(){return this.initialCenter}resetToInitialLocation(){this.resetLocation()}updateButtonConfig(e,t){const i=this.toolbarElement.querySelector(`[data-tool="${e}"]`);i&&(t.title&&(i.title=t.title),t.icon&&this.setButtonIcon(i,t.icon),t.size&&(i.style.width=`${t.size}px`,i.style.height=`${t.size}px`),t.color&&(i.style.background=t.color))}addCustomButton(e){const t={id:e.id,icon:typeof e.icon=="string"?e.icon:"",title:e.title,size:e.size,color:e.color,hoverColor:e.hoverColor,activeColor:e.activeColor},i=this.createButton(t);this.toolbarElement.appendChild(i),this.config.buttons||(this.config.buttons=[]),this.config.buttons.push(e)}removeButton(e){const t=this.toolbarElement.querySelector(`[data-tool="${e}"]`);t&&t.parentNode&&t.parentNode.removeChild(t),this.config.buttons&&(this.config.buttons=this.config.buttons.filter(i=>i.id!==e))}getButtonElement(e){return this.toolbarElement.querySelector(`[data-tool="${e}"]`)}setupDrawHelperCallbacks(){this.drawHelper.onDrawStart(()=>{console.log("开始绘制")}),this.drawHelper.onDrawEnd(e=>{if(e){if(console.log("绘制完成",e),e.polyline){const t=e.polyline.positions?.getValue(n.JulianDate.now());if(t&&this.measurementCallback?.onDistanceComplete){let i=0;for(let r=1;r<t.length;r++)i+=n.Cartesian3.distance(t[r-1],t[r]);this.measurementCallback.onDistanceComplete(t,i)}}else if(e.polygon){const t=e.polygon.hierarchy?.getValue(n.JulianDate.now());if(t&&this.measurementCallback?.onAreaComplete){const i=this.calculatePolygonArea(t.positions);this.measurementCallback.onAreaComplete(t.positions,i)}}}}),this.drawHelper.onEntityRemoved(e=>{console.log("实体被移除",e)})}calculatePolygonArea(e){if(e.length<3)return 0;const t=this.viewer.scene.globe.ellipsoid;let i=0;const r=e.length;for(let s=0;s<r;s++){const o=t.cartesianToCartographic(e[s]),a=t.cartesianToCartographic(e[(s+1)%r]);i+=(a.longitude-o.longitude)*(2+Math.sin(o.latitude)+Math.sin(a.latitude))}return i=Math.abs(i*6378137*6378137/2),i/1e6}createToolbar(){this.toolbarElement=document.createElement("div"),this.toolbarElement.className="cesium-map-toolbar",this.toolbarElement.style.cssText=`
1
+ (function(d,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("cesium")):typeof define=="function"&&define.amd?define(["exports","cesium"],m):(d=typeof globalThis<"u"?globalThis:d||self,m(d.VMapCesiumToolbar={},d.Cesium))})(this,(function(d,m){"use strict";function b(u){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const t in u)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(u,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>u[t]})}}return e.default=u,Object.freeze(e)}const n=b(m);class g{viewer;scene;entities;frustumPrimitives=[];drawMode=null;isDrawing=!1;tempPositions=[];tempEntities=[];tempLabelEntities=[];finishedEntities=[];finishedLabelEntities=[];finishedPointEntities=[];publicEntities=[];_doubleClickPending=!1;screenSpaceEventHandler=null;onDrawStartCallback=null;onDrawEndCallback=null;onEntityRemovedCallback=null;offsetHeight=2;constructor(e){if(!e||!(e instanceof n.Viewer))throw new Error("Invalid Cesium Viewer instance provided.");this.viewer=e,this.scene=e.scene,this.entities=e.entities,this.updateOffsetHeight(),this.scene.morphComplete.addEventListener(()=>{this.updateOffsetHeight()}),this.scene.globe.depthTestAgainstTerrain=!0}updateOffsetHeight(){this.scene.mode===n.SceneMode.SCENE3D?this.offsetHeight=100:this.offsetHeight=0}setOffsetHeight(e){this.offsetHeight=e}getOffsetHeight(){return this.offsetHeight}clearFrustum(){this.frustumPrimitives.forEach(e=>{e&&!e.isDestroyed()&&this.viewer.scene.primitives.remove(e)}),this.frustumPrimitives=[],this.screenSpaceEventHandler&&(this.screenSpaceEventHandler.destroy(),this.screenSpaceEventHandler=null)}drawFrustum(e={}){try{this.clearFrustum();const t=Math.max(1,Math.min(179,e.fov||60)),i=Math.max(.1,e.aspectRatio||1),s=Math.max(.1,e.near||1),o=Math.max(s+1,e.far||1e3),a=e.position||this.viewer.camera.positionWC,r=e.orientation||n.Quaternion.fromRotationMatrix(n.Matrix4.getRotation(this.viewer.camera.transform,new n.Matrix3)),l=new n.PerspectiveFrustum({fov:n.Math.toRadians(t),aspectRatio:i,near:s,far:o}),c=new n.FrustumGeometry({frustum:l,origin:a,orientation:r,vertexFormat:n.VertexFormat.POSITION_ONLY}),h=new n.GeometryInstance({geometry:c,attributes:{color:n.ColorGeometryInstanceAttribute.fromColor(e.fillColor||new n.Color(1,0,0,.3))}}),p=new n.Primitive({geometryInstances:h,appearance:new n.PerInstanceColorAppearance({closed:!0,flat:!0})}),y=new n.FrustumOutlineGeometry({frustum:l,origin:a,orientation:r}),x=new n.GeometryInstance({geometry:y,attributes:{color:n.ColorGeometryInstanceAttribute.fromColor(e.outlineColor||new n.Color(1,1,1,1))}}),E=new n.Primitive({geometryInstances:x,appearance:new n.PerInstanceColorAppearance({closed:!0,flat:!0})});this.viewer.scene.primitives.add(p),this.viewer.scene.primitives.add(E),this.frustumPrimitives.push(p,E),e.onRightClick&&this.screenSpaceEventHandler&&this.screenSpaceEventHandler.setInputAction(I=>{I.position&&e.onRightClick&&e.onRightClick(a)},n.ScreenSpaceEventType.RIGHT_CLICK)}catch(t){console.error("绘制视锥体时发生错误:",t),this.clearFrustum()}}startDrawingLine(){this.startDrawing("line")}startDrawingPolygon(){this.startDrawing("polygon")}startDrawingRectangle(){this.startDrawing("rectangle")}startDrawing(e){this.endDrawingInternal(!1),this.drawMode=e,this.isDrawing=!0,this.tempPositions=[],this.tempEntities=[],this.activateDrawingHandlers(),this.onDrawStartCallback&&this.onDrawStartCallback()}activateDrawingHandlers(){this.deactivateDrawingHandlers(),this.screenSpaceEventHandler=new n.ScreenSpaceEventHandler(this.scene.canvas),this.screenSpaceEventHandler.setInputAction(t=>{if(!this.isDrawing)return;if(this._doubleClickPending){this._doubleClickPending=!1;return}const i=this.pickGlobePosition(t.position);i&&this.addPoint(i)},n.ScreenSpaceEventType.LEFT_CLICK),this.screenSpaceEventHandler.setInputAction(()=>{!this.isDrawing||this.tempPositions.length===0||this.removeLastPoint()},n.ScreenSpaceEventType.RIGHT_CLICK),this.screenSpaceEventHandler.setInputAction(t=>{if(!this.isDrawing||this.tempPositions.length===0)return;const i=this.pickGlobePosition(t.endPosition);i&&this.updatePreview(i)},n.ScreenSpaceEventType.MOUSE_MOVE);const e=this.viewer.cesiumWidget.screenSpaceEventHandler.getInputAction(n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);this.viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK),this.screenSpaceEventHandler.setInputAction(t=>{this.isDrawing&&(this._doubleClickPending=!0,this.finishDrawing(),e&&this.viewer.cesiumWidget.screenSpaceEventHandler.setInputAction(e,n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK))},n.ScreenSpaceEventType.LEFT_DOUBLE_CLICK)}pickGlobePosition(e){const t=this.viewer.camera.getPickRay(e);if(t){const s=this.scene.globe.pick(t,this.scene);if(n.defined(s))return s}return this.viewer.camera.pickEllipsoid(e,this.scene.globe.ellipsoid)??null}addPoint(e){this.tempPositions.push(e.clone());const t=n.Cartographic.fromCartesian(e),i=n.Cartesian3.fromRadians(t.longitude,t.latitude,(t.height||0)+(this.drawMode!=="line"?0:this.offsetHeight)),s=this.entities.add({position:i,point:{pixelSize:8,color:n.Color.RED,outlineColor:n.Color.WHITE,outlineWidth:3,heightReference:n.HeightReference.RELATIVE_TO_GROUND,scaleByDistance:new n.NearFarScalar(150,1,15e6,.5)}});this.tempEntities.push(s),this.updateDrawingEntity()}removeLastPoint(){this.tempPositions.length>0&&(this.tempPositions.pop(),this.tempEntities.forEach(e=>{e&&this.entities.remove(e)}),this.tempEntities=[],this.tempLabelEntities.forEach(e=>{e&&this.entities.remove(e)}),this.tempLabelEntities=[],this.recreateRemainingEntities())}recreateRemainingEntities(){this.tempPositions.forEach(e=>{const t=n.Cartographic.fromCartesian(e),i=n.Cartesian3.fromRadians(t.longitude,t.latitude,(t.height||0)+this.offsetHeight),s=this.entities.add({position:i,point:{pixelSize:8,color:n.Color.RED,outlineColor:n.Color.WHITE,outlineWidth:3,heightReference:n.HeightReference.RELATIVE_TO_GROUND,scaleByDistance:new n.NearFarScalar(150,1,15e6,.5)}});this.tempEntities.push(s)}),this.updateDrawingEntity()}updatePreview(e){this.updateDrawingEntity(e)}updateDrawingEntity(e){const t=[];this.tempEntities.forEach(o=>{o&&(o.polyline||o.polygon||o.rectangle)&&t.push(o)}),t.forEach(o=>{this.entities.remove(o);const a=this.tempEntities.indexOf(o);a>-1&&this.tempEntities.splice(a,1)}),this.tempLabelEntities.forEach(o=>{o&&this.entities.remove(o)}),this.tempLabelEntities=[];const i=[...this.tempPositions];if(e&&i.push(e),i.length<2)return;let s;if(this.drawMode==="line"){if(this.offsetHeight>0){const o=i.map(a=>{const r=n.Cartographic.fromCartesian(a);return n.Cartesian3.fromRadians(r.longitude,r.latitude,(r.height||0)+this.offsetHeight)});s=this.entities.add({polyline:{positions:o,width:5,material:n.Color.YELLOW,clampToGround:!1}})}else s=this.entities.add({polyline:{positions:i,width:5,material:n.Color.YELLOW,clampToGround:!0}});this.tempEntities.push(s);for(let o=0;o<i.length-1;o++){const a=i[o],r=i[o+1],l=n.Cartesian3.distance(a,r);if(l>5){const c=n.Cartesian3.midpoint(a,r,new n.Cartesian3),h=o%2===0?-25:25,p=this.entities.add({position:c,label:{text:`${l.toFixed(2)} m`,font:"16px Arial",fillColor:n.Color.WHITE,outlineColor:n.Color.BLACK,outlineWidth:3,style:n.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new n.Cartesian2(0,h),heightReference:this.offsetHeight>0?n.HeightReference.RELATIVE_TO_GROUND:n.HeightReference.CLAMP_TO_GROUND,scale:1,showBackground:!0,backgroundColor:n.Color.BLACK.withAlpha(.8),backgroundPadding:new n.Cartesian2(6,3)}});this.tempLabelEntities.push(p)}}if(i.length>1){let o=0;for(let l=1;l<i.length;l++)o+=n.Cartesian3.distance(i[l-1],i[l]);let a=i[i.length-1];if(this.offsetHeight>0){const l=n.Cartographic.fromCartesian(a);a=n.Cartesian3.fromRadians(l.longitude,l.latitude,(l.height||0)+this.offsetHeight)}const r=this.entities.add({position:a,label:{text:`总长: ${o.toFixed(2)} m`,font:"18px Arial",fillColor:n.Color.YELLOW,outlineColor:n.Color.BLACK,outlineWidth:3,style:n.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new n.Cartesian2(0,40),heightReference:this.offsetHeight>0?n.HeightReference.NONE:n.HeightReference.CLAMP_TO_GROUND,scale:1,showBackground:!0,backgroundColor:n.Color.BLACK.withAlpha(.9),backgroundPadding:new n.Cartesian2(8,4)}});this.tempLabelEntities.push(r)}}else if(this.drawMode==="polygon")if(this.offsetHeight>0){const o=i.map(a=>{const r=n.Cartographic.fromCartesian(a);return n.Cartesian3.fromRadians(r.longitude,r.latitude,(r.height||0)+this.offsetHeight)});s=this.entities.add({polygon:{hierarchy:new n.CallbackProperty(()=>new n.PolygonHierarchy(o),!1),material:n.Color.LIGHTGREEN.withAlpha(.3),outline:!0,outlineColor:n.Color.GREEN,outlineWidth:2,heightReference:n.HeightReference.NONE}})}else s=this.entities.add({polygon:{hierarchy:new n.CallbackProperty(()=>new n.PolygonHierarchy(i),!1),material:n.Color.LIGHTGREEN.withAlpha(.3),outline:!0,outlineColor:n.Color.GREEN,outlineWidth:2,heightReference:n.HeightReference.CLAMP_TO_GROUND}});else if(this.drawMode==="rectangle"&&i.length>=2){const o=this.calculateRectangle(i[0],i[1]);this.offsetHeight>0?s=this.entities.add({rectangle:{coordinates:o,material:n.Color.GREEN.withAlpha(.5),heightReference:n.HeightReference.NONE,extrudedHeight:this.offsetHeight}}):s=this.entities.add({rectangle:{coordinates:o,material:n.Color.GREEN.withAlpha(.5),heightReference:n.HeightReference.CLAMP_TO_GROUND}})}s&&this.tempEntities.push(s)}finishDrawing(){if(this.tempPositions.length<(this.drawMode==="rectangle",2)){this.endDrawingInternal(!0);return}let e=null;const t=this.tempPositions.map(i=>i.clone());if(this.drawMode==="line")if(this.offsetHeight>0){const i=t.map(s=>{const o=n.Cartographic.fromCartesian(s);return n.Cartesian3.fromRadians(o.longitude,o.latitude,(o.height||0)+this.offsetHeight)});e=this.entities.add({name:"绘制的线",polyline:{positions:i,width:5,material:n.Color.YELLOW,clampToGround:!1}})}else e=this.entities.add({name:"绘制的线",polyline:{positions:t,width:5,material:n.Color.YELLOW,clampToGround:!0}});else if(this.drawMode==="polygon"){if(this.offsetHeight>0){const s=t.map(o=>{const a=n.Cartographic.fromCartesian(o);return n.Cartesian3.fromRadians(a.longitude,a.latitude,(a.height||0)+this.offsetHeight)});e=this.entities.add({name:"绘制的多边形区域",polygon:{hierarchy:new n.PolygonHierarchy(s),material:n.Color.LIGHTGREEN.withAlpha(.3),outline:!0,outlineColor:n.Color.GREEN,outlineWidth:2,heightReference:n.HeightReference.NONE}})}else e=this.entities.add({name:"绘制的多边形区域",polygon:{hierarchy:new n.PolygonHierarchy(t),material:n.Color.LIGHTGREEN.withAlpha(.3),outline:!0,outlineColor:n.Color.GREEN,outlineWidth:2,heightReference:n.HeightReference.CLAMP_TO_GROUND}});const i=this.calculatePolygonArea(t);if(i>0){const s=this.calculatePolygonCenter(t),o=this.entities.add({position:s,label:{text:`面积: ${i.toFixed(2)} km²`,font:"14px sans-serif",fillColor:n.Color.WHITE,outlineColor:n.Color.BLACK,outlineWidth:2,style:n.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new n.Cartesian2(0,-20),heightReference:n.HeightReference.CLAMP_TO_GROUND}});this.finishedLabelEntities.push(o)}}else if(this.drawMode==="rectangle"&&t.length>=2){const i=this.calculateRectangle(t[0],t[1]);this.offsetHeight>0?e=this.entities.add({name:"绘制的矩形",rectangle:{coordinates:i,material:n.Color.GREEN.withAlpha(.5),heightReference:n.HeightReference.NONE,extrudedHeight:this.offsetHeight}}):e=this.entities.add({name:"绘制的矩形",rectangle:{coordinates:i,material:n.Color.GREEN.withAlpha(.5),heightReference:n.HeightReference.CLAMP_TO_GROUND}});const s=this.calculateRectangleArea(i);if(s>0){const o=n.Rectangle.center(i),a=this.entities.add({position:n.Cartesian3.fromRadians(o.longitude,o.latitude),label:{text:`面积: ${s.toFixed(2)} km²`,font:"14px sans-serif",fillColor:n.Color.WHITE,outlineColor:n.Color.BLACK,outlineWidth:2,style:n.LabelStyle.FILL_AND_OUTLINE,pixelOffset:new n.Cartesian2(0,-20),heightReference:n.HeightReference.CLAMP_TO_GROUND}});this.finishedLabelEntities.push(a)}}e&&this.finishedEntities.push(e),this.tempLabelEntities.forEach(i=>{this.finishedLabelEntities.push(i)}),this.tempLabelEntities=[],this.tempEntities.forEach(i=>{i&&i.point?this.finishedPointEntities.push(i):this.entities.remove(i)}),this.tempEntities=[],this.tempPositions=[],this.drawMode=null,this.isDrawing=!1,this.deactivateDrawingHandlers(),this.onDrawEndCallback&&this.onDrawEndCallback(e)}endDrawingInternal(e){this.tempEntities.forEach(t=>{this.entities.remove(t)}),this.tempEntities=[],this.tempPositions=[],this.tempLabelEntities.forEach(t=>{this.entities.remove(t)}),this.tempLabelEntities=[],e&&(this.drawMode=null,this.isDrawing=!1,this.deactivateDrawingHandlers())}endDrawing(){this.isDrawing?this.finishDrawing():this.endDrawingInternal(!0)}deactivateDrawingHandlers(){this.screenSpaceEventHandler&&(this.screenSpaceEventHandler.destroy(),this.screenSpaceEventHandler=null)}clearAll(){this.endDrawing(),this.clearAllPoints(),this.finishedEntities.forEach(e=>{this.entities.remove(e)}),this.finishedEntities=[],this.finishedLabelEntities.forEach(e=>{e&&this.entities.remove(e)}),this.finishedLabelEntities=[],this.publicEntities.forEach(e=>{e&&this.entities.remove(e)}),this.publicEntities=[],this.tempEntities.forEach(e=>{e&&this.entities.remove(e)}),this.tempEntities=[],this.tempLabelEntities.forEach(e=>{e&&e.label&&this.entities.remove(e)}),this.tempLabelEntities=[],this.tempPositions=[]}clearAllEntities(){this.endDrawing(),this.entities.removeAll(),this.finishedEntities=[],this.finishedLabelEntities=[],this.finishedPointEntities=[],this.publicEntities=[],this.tempEntities=[],this.tempLabelEntities=[],this.tempPositions=[]}clearAllPoints(){this.finishedPointEntities.forEach(t=>{t&&this.entities.remove(t)}),this.finishedPointEntities=[],this.tempEntities.forEach(t=>{t&&t.point&&this.entities.remove(t)});const e=this.entities.values;for(let t=e.length-1;t>=0;t--){const i=e[t];i&&i.point&&this.entities.remove(i)}}removeEntity(e){const t=this.finishedEntities.indexOf(e);t>-1&&(this.entities.remove(e),this.finishedEntities.splice(t,1),this.onEntityRemovedCallback&&this.onEntityRemovedCallback(e))}getFinishedEntities(){return[...this.finishedEntities]}calculateRectangle(e,t){const i=n.Cartographic.fromCartesian(e),s=n.Cartographic.fromCartesian(t),o=Math.min(i.longitude,s.longitude),a=Math.max(i.longitude,s.longitude),r=Math.min(i.latitude,s.latitude),l=Math.max(i.latitude,s.latitude);return new n.Rectangle(o,r,a,l)}calculateRectangleArea(e){const t=e.west,i=e.south,s=e.east,o=e.north,a=n.Cartesian3.distance(n.Cartesian3.fromRadians(t,i),n.Cartesian3.fromRadians(s,i)),r=n.Cartesian3.distance(n.Cartesian3.fromRadians(t,i),n.Cartesian3.fromRadians(t,o));return a*r/1e6}calculatePolygonArea(e){if(e.length<3)return 0;const t=this.scene.globe.ellipsoid;let i=0;const s=e.length;for(let o=0;o<s;o++){const a=t.cartesianToCartographic(e[o]),r=t.cartesianToCartographic(e[(o+1)%s]);i+=(r.longitude-a.longitude)*(2+Math.sin(a.latitude)+Math.sin(r.latitude))}return i=Math.abs(i*6378137*6378137/2),i/1e6}calculatePolygonCenter(e){if(e.length===0)return n.Cartesian3.ZERO;let t=0,i=0,s=0;for(let o=0;o<e.length;o++)t+=e[o].x,i+=e[o].y,s+=e[o].z;return new n.Cartesian3(t/e.length,i/e.length,s/e.length)}onDrawStart(e){this.onDrawStartCallback=e}onDrawEnd(e){this.onDrawEndCallback=e}onEntityRemoved(e){this.onEntityRemovedCallback=e}drawMonitoringCircle(e,t,i,s,o){const a=o?.borderColor||"#0062FF",r=o?.fillColor||"#0062FF",l=o?.borderWidth||2,c=o?.name||"监控区域",h=this.entities.add({name:c,position:n.Cartesian3.fromDegrees(e,t,i),ellipse:{semiMajorAxis:s,semiMinorAxis:s,material:n.Color.fromCssColorString(r).withAlpha(.27),outline:!0,outlineColor:n.Color.fromCssColorString(a),outlineWidth:l,heightReference:n.HeightReference.CLAMP_TO_GROUND}});return this.publicEntities.push(h),h}drawVerticalLine(e,t,i,s){const o=s?.color||"#0062FF",a=s?.width||2;s?.dashPattern;const r=s?.name||"垂直线条",l=s?.groundHeight||0,c=n.Cartesian3.fromDegrees(e,t,l),h=n.Cartesian3.fromDegrees(e,t,i),p=this.entities.add({name:r,polyline:{positions:[c,h],width:a,material:new n.PolylineDashMaterialProperty({color:n.Color.fromCssColorString(o)}),clampToGround:!1}});return this.publicEntities.push(p),p}destroy(){this.deactivateDrawingHandlers(),this.clearFrustum()}}window.DrawHelper=g;class f{viewer;drawHelper;container;toolbarElement;config;searchCallback;measurementCallback;zoomCallback;initialCenter;isFullscreen=!1;currentMapType="imagery";mapTypes=[{id:"normal",name:"天地图-普通",thumbnail:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjQwIiBoZWlnaHQ9IjQwIiBmaWxsPSIjZjBmMGYwIi8+CjxwYXRoIGQ9Ik0xMCAxMEgzMFYzMEgxMFYxMFoiIGZpbGw9IiNlMGUwZTAiLz4KPC9zdmc+",provider:new n.UrlTemplateImageryProvider({url:"https://t{s}.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}&tk=your_token",subdomains:["0","1","2","3","4","5","6","7"],minimumLevel:1,maximumLevel:18,credit:"© 天地图"})},{id:"3d",name:"天地图-三维",thumbnail:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjQwIiBoZWlnaHQ9IjQwIiBmaWxsPSIjZjBmMGYwIi8+CjxwYXRoIGQ9Ik0xMCAxMEgzMFYzMEgxMFYxMFoiIGZpbGw9IiNlMGUwZTAiLz4KPC9zdmc+",provider:new n.UrlTemplateImageryProvider({url:"https://t{s}.tianditu.gov.cn/ter_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ter&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}&tk=your_token",subdomains:["0","1","2","3","4","5","6","7"],minimumLevel:1,maximumLevel:18,credit:"© 天地图"})},{id:"imagery",name:"天地图-影像",thumbnail:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjQwIiBoZWlnaHQ9IjQwIiBmaWxsPSIjZjBmMGYwIi8+CjxwYXRoIGQ9Ik0xMCAxMEgzMFYzMEgxMFYxMFoiIGZpbGw9IiNlMGUwZTAiLz4KPC9zdmc+",provider:new n.UrlTemplateImageryProvider({url:"https://t{s}.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}&tk=your_token",subdomains:["0","1","2","3","4","5","6","7"],minimumLevel:1,maximumLevel:18,credit:"© 天地图"})},{id:"terrain",name:"天地图-地形",thumbnail:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjQwIiBoZWlnaHQ9IjQwIiBmaWxsPSIjZjBmMGYwIi8+CjxwYXRoIGQ9Ik0xMCAxMEgzMFYzMEgxMFYxMFoiIGZpbGw9IiNlMGUwZTAiLz4KPC9zdmc+",provider:new n.UrlTemplateImageryProvider({url:"https://t{s}.tianditu.gov.cn/ter_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ter&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}&tk=your_token",subdomains:["0","1","2","3","4","5","6","7"],minimumLevel:1,maximumLevel:18,credit:"© 天地图"})}];constructor(e,t,i={},s,o){this.viewer=e,this.container=t,this.config={position:"bottom-right",buttonSize:40,buttonSpacing:8,backgroundColor:"rgba(255, 255, 255, 0.9)",borderColor:"#e0e0e0",borderRadius:6,boxShadow:"0 2px 10px rgba(0, 0, 0, 0.1)",zIndex:1e3,...i},this.searchCallback=s?.search,this.measurementCallback=s?.measurement,this.zoomCallback=s?.zoom,this.initialCenter=o,this.drawHelper=new g(e),this.setupDrawHelperCallbacks(),this.createToolbar()}setInitialCenter(e){this.initialCenter=e}getInitialCenter(){return this.initialCenter}resetToInitialLocation(){this.resetLocation()}updateButtonConfig(e,t){const i=this.toolbarElement.querySelector(`[data-tool="${e}"]`);i&&(t.title&&(i.title=t.title),t.icon&&this.setButtonIcon(i,t.icon),t.size&&(i.style.width=`${t.size}px`,i.style.height=`${t.size}px`),t.color&&(i.style.color=t.color),t.backgroundColor&&(i.style.background=t.backgroundColor),t.borderColor&&(i.style.borderColor=t.borderColor),t.borderWidth&&(i.style.borderWidth=t.borderWidth+"px"),t.borderStyle&&(i.style.borderStyle=t.borderStyle),t.padding&&(i.style.padding=t.padding),t.activeIcon&&this.setButtonIcon(i,t.activeIcon))}addCustomButton(e){const t={id:e.id,icon:typeof e.icon=="string"?e.icon:"",title:e.title,size:e.size,color:e.color,hoverColor:e.hoverColor,activeColor:e.activeColor,backgroundColor:e.backgroundColor},i=this.createButton(t);this.toolbarElement.appendChild(i),this.config.buttons||(this.config.buttons=[]),this.config.buttons.push(e)}removeButton(e){const t=this.toolbarElement.querySelector(`[data-tool="${e}"]`);t&&t.parentNode&&t.parentNode.removeChild(t),this.config.buttons&&(this.config.buttons=this.config.buttons.filter(i=>i.id!==e))}getButtonElement(e){return this.toolbarElement.querySelector(`[data-tool="${e}"]`)}setupDrawHelperCallbacks(){this.drawHelper.onDrawStart(()=>{console.log("开始绘制")}),this.drawHelper.onDrawEnd(e=>{if(e){if(console.log("绘制完成",e),e.polyline){const t=e.polyline.positions?.getValue(n.JulianDate.now());if(t&&this.measurementCallback?.onDistanceComplete){let i=0;for(let s=1;s<t.length;s++)i+=n.Cartesian3.distance(t[s-1],t[s]);this.measurementCallback.onDistanceComplete(t,i)}}else if(e.polygon){const t=e.polygon.hierarchy?.getValue(n.JulianDate.now());if(t&&this.measurementCallback?.onAreaComplete){const i=this.calculatePolygonArea(t.positions);this.measurementCallback.onAreaComplete(t.positions,i)}}}}),this.drawHelper.onEntityRemoved(e=>{console.log("实体被移除",e)})}calculatePolygonArea(e){if(e.length<3)return 0;const t=this.viewer.scene.globe.ellipsoid;let i=0;const s=e.length;for(let o=0;o<s;o++){const a=t.cartesianToCartographic(e[o]),r=t.cartesianToCartographic(e[(o+1)%s]);i+=(r.longitude-a.longitude)*(2+Math.sin(a.latitude)+Math.sin(r.latitude))}return i=Math.abs(i*6378137*6378137/2),i/1e6}createToolbar(){this.toolbarElement=document.createElement("div"),this.toolbarElement.className="cesium-map-toolbar",this.toolbarElement.style.cssText=`
2
2
  position: absolute;
3
3
  ${this.config.position?.includes("right")?"right":"left"}: 10px;
4
4
  ${this.config.position?.includes("bottom")?"bottom":"top"}: 10px;
@@ -11,23 +11,33 @@
11
11
  display: flex;
12
12
  flex-direction: column;
13
13
  gap: ${this.config.buttonSpacing}px;
14
- `,this.getButtonConfigs().forEach(t=>{const i=this.createButton(t);this.toolbarElement.appendChild(i)}),this.container.appendChild(this.toolbarElement)}getButtonConfigs(){const e=[{id:"search",icon:"🔍",title:"搜索"},{id:"measure",icon:"📏",title:"测量"},{id:"view2d3d",icon:"2D",title:"2D或3D"},{id:"layers",icon:"📚",title:"图层切换"},{id:"location",icon:"🎯",title:"定位"},{id:"zoom-in",icon:"🔍+",title:"放大"},{id:"zoom-out",icon:"🔍-",title:"缩小"},{id:"fullscreen",icon:"⛶",title:"全屏"}];return this.config.buttons&&this.config.buttons.length>0?this.config.buttons.map(t=>({id:t.id,icon:typeof t.icon=="string"?t.icon:"",title:t.title,size:t.size,color:t.color,hoverColor:t.hoverColor,activeColor:t.activeColor})):e}createButton(e){const t=document.createElement("div");t.className="cesium-toolbar-button",t.setAttribute("data-tool",e.id),t.title=e.title;const i=e.size||this.config.buttonSize,r=e.color||"rgba(66, 133, 244, 0.4)",s=e.hoverColor||"rgba(51, 103, 214, 0.9)";return t.style.cssText=`
14
+ `,this.getButtonConfigs().forEach(t=>{const i=this.createButton(t);this.toolbarElement.appendChild(i)}),this.container.appendChild(this.toolbarElement)}getButtonConfigs(){const e=[{id:"search",icon:"🔍",title:"搜索"},{id:"measure",icon:"📏",title:"测量"},{id:"view2d3d",icon:"2D",title:"2D或3D"},{id:"layers",icon:"📚",title:"图层切换"},{id:"location",icon:"🎯",title:"定位"},{id:"zoom-in",icon:"🔍+",title:"放大"},{id:"zoom-out",icon:"🔍-",title:"缩小"},{id:"fullscreen",icon:"⛶",title:"全屏"}],t=i=>e.find(s=>s.id===i);return this.config.buttons&&this.config.buttons.length>0?this.config.buttons.map(i=>{const s=t(i.id);return{id:i.id||s?.id||"",icon:typeof i.icon=="string"?i.icon:s?.icon||"",title:i.title||s?.title||"",size:typeof i.size=="number"?i.size:typeof s?.size=="number"?s.size:void 0,backgroundColor:i.backgroundColor||s?.backgroundColor||"",borderColor:i.borderColor||s?.borderColor||"",borderWidth:i.borderWidth||s?.borderWidth||1,borderStyle:i.borderStyle||s?.borderStyle||"solid",color:i.color||s?.color||"rgba(66, 133, 244, 0.4)"}}):e}createButton(e){const t=document.createElement("div");t.className="cesium-toolbar-button",t.setAttribute("data-tool",e.id),t.title=e.title;const i=e.size||this.config.buttonSize,s=e.color||"rgba(66, 133, 244, 0.4)",o=e.backgroundColor||"rgba(66, 133, 244, 0.4)",a=e.borderColor||"rgba(66, 133, 244, 0.4)",r=e.borderWidth||1,l=e.borderStyle||"solid";return t.style.cssText=`
15
15
  width: ${i}px;
16
16
  height: ${i}px;
17
17
  display: flex;
18
18
  align-items: center;
19
19
  justify-content: center;
20
- background: ${r};
21
- color: white;
22
- border: none;
23
- border-radius: 4px;
20
+ background: ${o};
21
+ color: ${s};
22
+ border-width: ${r}px;
23
+ border-style: ${l};
24
+ border-color: ${a};
24
25
  cursor: pointer;
25
- font-size: 14px;
26
26
  font-weight: bold;
27
27
  transition: all 0.2s ease;
28
28
  user-select: none;
29
29
  position: relative;
30
- `,this.setButtonIcon(t,e.icon),t.addEventListener("mouseenter",()=>{t.style.background=s,t.style.transform="scale(1.05)"}),t.addEventListener("mouseleave",()=>{t.style.background=r,t.style.transform="scale(1)"}),this.setupButtonEvents(t,e),t}setButtonIcon(e,t){typeof t=="string"?e.innerHTML=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t))}setupButtonEvents(e,t){const i=this.config.buttons?.find(r=>r.id===t.id);i?.onClick?e.addEventListener("click",r=>{r.stopPropagation(),i.onClick(t.id,e)}):["search","measure","layers"].includes(t.id)?(e.addEventListener("mouseenter",()=>{this.handleButtonClick(t.id,e)}),e.addEventListener("mouseleave",()=>{this.closeMenuOnButtonLeave(t.id)})):e.addEventListener("click",r=>{r.stopPropagation(),this.handleButtonClick(t.id,e)})}closeMenuOnButtonLeave(e){setTimeout(()=>{switch(e){case"search":const t=this.toolbarElement.querySelector(".search-container");t&&!t.matches(":hover")&&t.remove();break;case"measure":const i=this.toolbarElement.querySelector(".measurement-menu");i&&!i.matches(":hover")&&i.remove();break;case"layers":const r=this.toolbarElement.querySelector(".layers-menu");r&&!r.matches(":hover")&&r.remove();break}},100)}handleButtonClick(e,t){switch(e){case"search":this.toggleSearch(t);break;case"measure":this.toggleMeasurement(t);break;case"view2d3d":this.toggle2D3D(t);break;case"layers":this.toggleLayers(t);break;case"location":this.resetLocation();break;case"zoom-in":this.zoomIn();break;case"zoom-out":this.zoomOut();break;case"fullscreen":this.toggleFullscreen();break}}toggleSearch(e){if(this.toolbarElement.querySelector(".search-container"))return;const i=document.createElement("div");i.className="search-container",i.style.cssText=`
30
+ `,this.setButtonIcon(t,e.icon),t.addEventListener("mouseenter",()=>{t.style.transform="scale(1.05)"}),t.addEventListener("mouseleave",()=>{t.style.transform="scale(1)"}),this.setupButtonEvents(t,e),t}setButtonIcon(e,t){t instanceof HTMLElement?(e.innerHTML="",e.appendChild(t)):typeof t=="string"&&(this.isImagePath(t)?this.loadImageIcon(e,t):e.innerHTML=t)}isImagePath(e){return/\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/i.test(e)}loadImageIcon(e,t){const i=new Image,s=e.getBoundingClientRect(),o=window.getComputedStyle(e),a=s.width||parseInt(o.width)||36,r=s.height||parseInt(o.height)||36,l=Math.min(a,r)*.6,c=Math.min(a,r)*.6;i.width=l,i.height=c,i.onload=()=>{e.appendChild(i)},i.onerror=()=>{console.warn(`Failed to load icon: ${t}`),this.setDefaultIcon(e,t)},i.src=t}setDefaultIcon(e,t){const i=t.split("/").pop()?.split(".")[0]||"icon";e.style.backgroundImage="none",e.style.backgroundColor="#ccc",e.style.position="relative";const s=document.createElement("div");s.style.cssText=`
31
+ position: absolute;
32
+ top: 50%;
33
+ left: 50%;
34
+ transform: translate(-50%, -50%);
35
+ font-size: 12px;
36
+ color: #666;
37
+ font-weight: bold;
38
+ text-align: center;
39
+ line-height: 1;
40
+ `,s.textContent=i.charAt(0).toUpperCase(),e.innerHTML="",e.appendChild(s)}setupButtonEvents(e,t){const i=this.config.buttons?.find(s=>s.id===t.id);i?.onClick?e.addEventListener("click",s=>{s.stopPropagation(),i.onClick(t.id,e)}):["search","measure","layers"].includes(t.id)?t.id==="search"?e.addEventListener("click",s=>{s.stopPropagation(),this.handleButtonClick(t.id,e)}):(e.addEventListener("mouseenter",()=>{this.handleButtonClick(t.id,e)}),e.addEventListener("mouseleave",()=>{this.closeMenuOnButtonLeave(t.id)})):e.addEventListener("click",s=>{s.stopPropagation(),this.handleButtonClick(t.id,e)})}closeMenuOnButtonLeave(e){setTimeout(()=>{switch(e){case"measure":const t=this.toolbarElement.querySelector(".measurement-menu");t&&!t.matches(":hover")&&t.remove();break;case"layers":const i=this.toolbarElement.querySelector(".layers-menu");i&&!i.matches(":hover")&&i.remove();break}},100)}handleButtonClick(e,t){switch(e){case"search":this.toggleSearch(t);break;case"measure":this.toggleMeasurement(t);break;case"view2d3d":this.toggle2D3D(t);break;case"layers":this.toggleLayers(t);break;case"location":this.resetLocation();break;case"zoom-in":this.zoomIn();break;case"zoom-out":this.zoomOut();break;case"fullscreen":this.toggleFullscreen();break}}toggleSearch(e){const t=this.toolbarElement.querySelector(".search-container");if(t){t.remove();return}const i=document.createElement("div");i.className="search-container",i.style.cssText=`
31
41
  position: absolute;
32
42
  right: 100%;
33
43
  top: 0;
@@ -39,25 +49,25 @@
39
49
  padding: 8px;
40
50
  min-width: 200px;
41
51
  z-index: 1001;
42
- `;const r=document.createElement("input");r.type="text",r.placeholder="请输入地址",r.style.cssText=`
52
+ `;const s=document.createElement("input");s.type="text",s.placeholder="请输入地址",s.style.cssText=`
43
53
  padding: 6px 8px;
44
54
  border: 1px solid #ddd;
45
55
  border-radius: 3px;
46
56
  font-size: 14px;
47
57
  outline: none;
48
- `;const s=document.createElement("div");s.className="search-results",s.style.cssText=`
58
+ `;const o=document.createElement("div");o.className="search-results",o.style.cssText=`
49
59
  margin-top: 8px;
50
60
  max-height: 200px;
51
61
  overflow-y: auto;
52
- `,i.appendChild(r),i.appendChild(s),this.toolbarElement.insertBefore(i,e);let o;r.addEventListener("input",()=>{clearTimeout(o);const l=r.value.trim();if(this.searchCallback?.onSearchInput){this.searchCallback.onSearchInput(l,s);return}if(l.length<2){s.innerHTML="";return}o=setTimeout(async()=>{if(this.searchCallback?.onSearch)try{const c=await this.searchCallback.onSearch(l);this.displaySearchResults(c,s)}catch(c){console.error("搜索失败:",c),s.innerHTML='<div style="padding: 8px; color: #666;">搜索失败</div>'}else this.performDefaultSearch(l,s)},300)});const a=()=>{i.remove()};i.addEventListener("mouseleave",a)}displaySearchResults(e,t){if(this.searchCallback?.onSearchResults){this.searchCallback.onSearchResults(e,t);return}if(t.innerHTML="",e.length===0){t.innerHTML='<div style="padding: 8px; color: #666;">未找到相关地址</div>';return}e.forEach(i=>{const r=document.createElement("div");r.style.cssText=`
62
+ `,i.appendChild(s),i.appendChild(o),this.toolbarElement.insertBefore(i,e);let a;s.addEventListener("input",()=>{clearTimeout(a);const c=s.value.trim();if(this.searchCallback?.onSearchInput){this.searchCallback.onSearchInput(c,o);return}if(c.length<2){o.innerHTML="";return}a=setTimeout(async()=>{if(this.searchCallback?.onSearch)try{const h=await this.searchCallback.onSearch(c);this.displaySearchResults(h,o)}catch(h){console.error("搜索失败:",h),o.innerHTML='<div style="padding: 8px; color: #666;">搜索失败</div>'}else this.performDefaultSearch(c,o)},300)});const r=c=>{!i.contains(c.target)&&!e.contains(c.target)&&(i.remove(),document.removeEventListener("click",r),document.removeEventListener("keydown",l))},l=c=>{c.key==="Escape"&&(i.remove(),document.removeEventListener("click",r),document.removeEventListener("keydown",l))};setTimeout(()=>{document.addEventListener("click",r),document.addEventListener("keydown",l),s.focus()},100)}displaySearchResults(e,t){if(this.searchCallback?.onSearchResults){this.searchCallback.onSearchResults(e,t);return}if(t.innerHTML="",e.length===0){t.innerHTML='<div style="padding: 8px; color: #666;">未找到相关地址</div>';return}e.forEach(i=>{const s=document.createElement("div");s.style.cssText=`
53
63
  padding: 8px;
54
64
  border-bottom: 1px solid #f0f0f0;
55
65
  cursor: pointer;
56
66
  transition: background-color 0.2s;
57
- `,r.innerHTML=`
67
+ `,s.innerHTML=`
58
68
  <div style="font-weight: bold; margin-bottom: 2px;">${i.name}</div>
59
69
  <div style="font-size: 12px; color: #666;">${i.address}</div>
60
- `,r.addEventListener("mouseenter",()=>{r.style.backgroundColor="#f5f5f5"}),r.addEventListener("mouseleave",()=>{r.style.backgroundColor="transparent"}),r.addEventListener("click",()=>{this.selectSearchResult(i),t.parentElement?.remove()}),t.appendChild(r)})}selectSearchResult(e){this.viewer.camera.flyTo({destination:n.Cartesian3.fromDegrees(e.longitude,e.latitude,e.height||1e3),duration:1}),this.searchCallback?.onSelect&&this.searchCallback.onSelect(e)}performDefaultSearch(e,t){const i=[{name:"人工智能产业园",address:"浙江省杭州市西湖区",longitude:120.16,latitude:30.28,height:100},{name:"人工智能产业园",address:"浙江省杭州市西湖区",longitude:120.16,latitude:30.28,height:100},{name:"人工智能产业园",address:"浙江省杭州市西湖区",longitude:120.16,latitude:30.28,height:100}];this.displaySearchResults(i,t)}toggleMeasurement(e){if(this.toolbarElement.querySelector(".measurement-menu"))return;const i=document.createElement("div");i.className="measurement-menu",i.style.cssText=`
70
+ `,s.addEventListener("mouseenter",()=>{s.style.backgroundColor="#f5f5f5"}),s.addEventListener("mouseleave",()=>{s.style.backgroundColor="transparent"}),s.addEventListener("click",()=>{this.selectSearchResult(i),t.parentElement?.remove()}),t.appendChild(s)})}selectSearchResult(e){this.viewer.camera.flyTo({destination:n.Cartesian3.fromDegrees(e.longitude,e.latitude,e.height||1e3),duration:1}),this.searchCallback?.onSelect&&this.searchCallback.onSelect(e)}performDefaultSearch(e,t){const i=[{name:"人工智能产业园",address:"浙江省杭州市西湖区",longitude:120.16,latitude:30.28,height:100},{name:"人工智能产业园",address:"浙江省杭州市西湖区",longitude:120.16,latitude:30.28,height:100},{name:"人工智能产业园",address:"浙江省杭州市西湖区",longitude:120.16,latitude:30.28,height:100}];this.displaySearchResults(i,t)}toggleMeasurement(e){if(this.toolbarElement.querySelector(".measurement-menu"))return;const i=document.createElement("div");i.className="measurement-menu",i.style.cssText=`
61
71
  position: absolute;
62
72
  right: 100%;
63
73
  top: 0;
@@ -69,14 +79,14 @@
69
79
  padding: 4px 0;
70
80
  min-width: 120px;
71
81
  z-index: 1001;
72
- `,[{id:"measure-area",text:"测面积",icon:"📐"},{id:"measure-distance",text:"测距",icon:"📏"},{id:"clear-measurement",text:"清除",icon:"🗑️"}].forEach(o=>{const a=document.createElement("div");a.style.cssText=`
82
+ `,[{id:"measure-area",text:"测面积",icon:"📐"},{id:"measure-distance",text:"测距",icon:"📏"},{id:"clear-measurement",text:"清除",icon:"🗑️"}].forEach(a=>{const r=document.createElement("div");r.style.cssText=`
73
83
  padding: 8px 12px;
74
84
  cursor: pointer;
75
85
  display: flex;
76
86
  align-items: center;
77
87
  gap: 8px;
78
88
  transition: background-color 0.2s;
79
- `,a.innerHTML=`${o.icon} ${o.text}`,a.addEventListener("mouseenter",()=>{a.style.backgroundColor="#f5f5f5"}),a.addEventListener("mouseleave",()=>{a.style.backgroundColor="transparent"}),a.addEventListener("click",()=>{this.handleMeasurementAction(o.id),i.remove()}),i.appendChild(a)}),this.toolbarElement.insertBefore(i,e);const s=()=>{i.remove()};i.addEventListener("mouseleave",s)}handleMeasurementAction(e){switch(e){case"measure-area":this.drawHelper.startDrawingPolygon();break;case"measure-distance":this.drawHelper.startDrawingLine();break;case"clear-measurement":this.drawHelper.clearAll(),this.measurementCallback?.onClear&&this.measurementCallback.onClear();break}}toggle2D3D(e){const i=this.viewer.scene.mode===n.SceneMode.SCENE3D?n.SceneMode.SCENE2D:n.SceneMode.SCENE3D;this.viewer.scene.mode=i,e.innerHTML=i===n.SceneMode.SCENE3D?"3D":"2D"}toggleLayers(e){if(this.toolbarElement.querySelector(".layers-menu"))return;const i=document.createElement("div");i.className="layers-menu",i.style.cssText=`
89
+ `,r.innerHTML=`${a.icon} ${a.text}`,r.addEventListener("mouseenter",()=>{r.style.backgroundColor="#f5f5f5"}),r.addEventListener("mouseleave",()=>{r.style.backgroundColor="transparent"}),r.addEventListener("click",()=>{this.handleMeasurementAction(a.id),i.remove()}),i.appendChild(r)}),this.toolbarElement.insertBefore(i,e);const o=()=>{i.remove()};i.addEventListener("mouseleave",o)}handleMeasurementAction(e){switch(e){case"measure-area":this.drawHelper.startDrawingPolygon();break;case"measure-distance":this.drawHelper.startDrawingLine();break;case"clear-measurement":this.drawHelper.clearAll(),this.measurementCallback?.onClear&&this.measurementCallback.onClear();break}}toggle2D3D(e){const i=this.viewer.scene.mode===n.SceneMode.SCENE3D?n.SceneMode.SCENE2D:n.SceneMode.SCENE3D;this.viewer.scene.mode=i,e.innerHTML=i===n.SceneMode.SCENE3D?"3D":"2D"}toggleLayers(e){if(this.toolbarElement.querySelector(".layers-menu"))return;const i=document.createElement("div");i.className="layers-menu",i.style.cssText=`
80
90
  position: absolute;
81
91
  right: 100%;
82
92
  top: 0;
@@ -91,11 +101,11 @@
91
101
  z-index: 1001;
92
102
  display: flex;
93
103
  flex-direction: column;
94
- `;const r=document.createElement("div");r.style.cssText=`
104
+ `;const s=document.createElement("div");s.style.cssText=`
95
105
  display: flex;
96
106
  flex-direction: column;
97
107
  gap: 4px;
98
- `,r.innerHTML='<div style="font-weight: bold; margin-bottom: 8px; color: #333; font-size: 14px;">地图类型</div>',this.mapTypes.forEach(o=>{const a=document.createElement("div");a.style.cssText=`
108
+ `,s.innerHTML='<div style="font-weight: bold; margin-bottom: 8px; color: #333; font-size: 14px;">地图类型</div>',this.mapTypes.forEach(a=>{const r=document.createElement("div");r.style.cssText=`
99
109
  display: flex;
100
110
  align-items: center;
101
111
  gap: 8px;
@@ -105,20 +115,20 @@
105
115
  transition: background-color 0.2s;
106
116
  width: 100%;
107
117
  box-sizing: border-box;
108
- ${o.id===this.currentMapType?"background-color: #e3f2fd;":""}
109
- `;const l=document.createElement("img");l.src=o.thumbnail,l.style.cssText=`
118
+ ${a.id===this.currentMapType?"background-color: #e3f2fd;":""}
119
+ `;const l=document.createElement("img");l.src=a.thumbnail,l.style.cssText=`
110
120
  width: 24px;
111
121
  height: 24px;
112
122
  border-radius: 3px;
113
123
  flex-shrink: 0;
114
- `;const c=document.createElement("span");c.textContent=o.name,c.style.cssText=`
124
+ `;const c=document.createElement("span");c.textContent=a.name,c.style.cssText=`
115
125
  font-size: 14px;
116
126
  color: #333;
117
127
  flex: 1;
118
- `;const m=document.createElement("span");o.id===this.currentMapType&&(m.textContent="✓",m.style.cssText=`
128
+ `;const h=document.createElement("span");a.id===this.currentMapType&&(h.textContent="✓",h.style.cssText=`
119
129
  color: #1976d2;
120
130
  font-weight: bold;
121
131
  font-size: 16px;
122
132
  flex-shrink: 0;
123
- `),a.appendChild(l),a.appendChild(c),a.appendChild(m),a.addEventListener("mouseenter",()=>{o.id!==this.currentMapType&&(a.style.backgroundColor="#f5f5f5")}),a.addEventListener("mouseleave",()=>{o.id!==this.currentMapType&&(a.style.backgroundColor="transparent")}),a.addEventListener("click",()=>{this.switchMapType(o.id),i.remove()}),r.appendChild(a)}),i.appendChild(r),this.toolbarElement.insertBefore(i,e);const s=()=>{i.remove()};i.addEventListener("mouseleave",s)}switchMapType(e){const t=this.mapTypes.find(i=>i.id===e);t&&(this.viewer.imageryLayers.removeAll(),this.viewer.imageryLayers.addImageryProvider(t.provider),this.currentMapType=e)}resetLocation(){if(!this.initialCenter){console.warn("未设置初始中心点,无法执行复位操作");return}this.viewer.camera.flyTo({destination:n.Cartesian3.fromDegrees(this.initialCenter.longitude,this.initialCenter.latitude,this.initialCenter.height),duration:1})}zoomIn(){const e=this.viewer.camera.positionCartographic.height;this.viewer.camera.zoomIn(this.viewer.camera.positionCartographic.height*.5);const t=this.viewer.camera.positionCartographic.height;this.zoomCallback?.onZoomIn&&this.zoomCallback.onZoomIn(e,t)}zoomOut(){const e=this.viewer.camera.positionCartographic.height;this.viewer.camera.zoomOut(this.viewer.camera.positionCartographic.height*.5);const t=this.viewer.camera.positionCartographic.height;this.zoomCallback?.onZoomOut&&this.zoomCallback.onZoomOut(e,t)}toggleFullscreen(){this.isFullscreen?this.exitFullscreen():this.enterFullscreen()}enterFullscreen(){const e=this.viewer.container;e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen(),this.isFullscreen=!0;const t=()=>{!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.msFullscreenElement&&(this.isFullscreen=!1,document.removeEventListener("fullscreenchange",t),document.removeEventListener("webkitfullscreenchange",t),document.removeEventListener("msfullscreenchange",t))};document.addEventListener("fullscreenchange",t),document.addEventListener("webkitfullscreenchange",t),document.addEventListener("msfullscreenchange",t)}exitFullscreen(){document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen(),this.isFullscreen=!1}destroy(){this.toolbarElement&&this.toolbarElement.parentNode&&this.toolbarElement.parentNode.removeChild(this.toolbarElement),this.drawHelper.destroy()}}function w(){return new n.UrlTemplateImageryProvider({url:"https://webst0{s}.is.autonavi.com/appmaptile?style=7&x={x}&y={y}&z={z}",subdomains:["1","2","3","4"],minimumLevel:3,maximumLevel:18,credit:"© 高德地图"})}async function C(h,e,t={longitude:120.2052342,latitude:30.2489634,height:1e3,pitch:-60,heading:0}){u.Ion.defaultAccessToken="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3M2M3NWU1Ni0xZmJkLTRkNjAtOTk4NC0wZDZhNWFiOWJlZDEiLCJpZCI6MzMxNTg1LCJpYXQiOjE3NTUyMjQ2MzB9.WBUG7ctHKtOrnay1ng8JNfaNgngbkNgOmRXP59OJ7ME";const i=new u.Viewer(h,{timeline:!1,animation:!1,baseLayerPicker:!1,...e});return!e.terrainProvider&&!e.terrain&&(i.terrainProvider=await u.createWorldTerrainAsync()),e.mapType==="gaode"&&(i.imageryLayers.removeAll(),i.imageryLayers.addImageryProvider(w())),t&&i.camera.flyTo({destination:n.Cartesian3.fromDegrees(t.longitude,t.latitude,t.height),orientation:{heading:n.Math.toRadians(t.heading||0),pitch:n.Math.toRadians(t.pitch||-30)}}),i.cesiumWidget.creditContainer.style.display="none",{viewer:i,initialCenter:t}}const v={CesiumMapToolbar:f,DrawHelper:p,initCesium:C};d.CesiumMapToolbar=f,d.DrawHelper=p,d.default=v,d.initCesium=C,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
133
+ `),r.appendChild(l),r.appendChild(c),r.appendChild(h),r.addEventListener("mouseenter",()=>{a.id!==this.currentMapType&&(r.style.backgroundColor="#f5f5f5")}),r.addEventListener("mouseleave",()=>{a.id!==this.currentMapType&&(r.style.backgroundColor="transparent")}),r.addEventListener("click",()=>{this.switchMapType(a.id),i.remove()}),s.appendChild(r)}),i.appendChild(s),this.toolbarElement.insertBefore(i,e);const o=()=>{i.remove()};i.addEventListener("mouseleave",o)}switchMapType(e){const t=this.mapTypes.find(i=>i.id===e);t&&(this.viewer.imageryLayers.removeAll(),this.viewer.imageryLayers.addImageryProvider(t.provider),this.currentMapType=e)}resetLocation(){if(!this.initialCenter){console.warn("未设置初始中心点,无法执行复位操作");return}this.viewer.camera.flyTo({destination:n.Cartesian3.fromDegrees(this.initialCenter.longitude,this.initialCenter.latitude,this.initialCenter.height),duration:1})}zoomIn(){const e=this.viewer.camera.positionCartographic.height;this.viewer.camera.zoomIn(this.viewer.camera.positionCartographic.height*.5);const t=this.viewer.camera.positionCartographic.height;this.zoomCallback?.onZoomIn&&this.zoomCallback.onZoomIn(e,t)}zoomOut(){const e=this.viewer.camera.positionCartographic.height;this.viewer.camera.zoomOut(this.viewer.camera.positionCartographic.height*.5);const t=this.viewer.camera.positionCartographic.height;this.zoomCallback?.onZoomOut&&this.zoomCallback.onZoomOut(e,t)}toggleFullscreen(){this.isFullscreen?this.exitFullscreen():this.enterFullscreen()}enterFullscreen(){const e=this.viewer.container;e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen(),this.isFullscreen=!0;const t=()=>{!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.msFullscreenElement&&(this.isFullscreen=!1,document.removeEventListener("fullscreenchange",t),document.removeEventListener("webkitfullscreenchange",t),document.removeEventListener("msfullscreenchange",t))};document.addEventListener("fullscreenchange",t),document.addEventListener("webkitfullscreenchange",t),document.addEventListener("msfullscreenchange",t)}exitFullscreen(){document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen(),this.isFullscreen=!1}destroy(){this.toolbarElement&&this.toolbarElement.parentNode&&this.toolbarElement.parentNode.removeChild(this.toolbarElement),this.drawHelper.destroy()}}function w(){return new n.UrlTemplateImageryProvider({url:"https://webst0{s}.is.autonavi.com/appmaptile?style=7&x={x}&y={y}&z={z}",subdomains:["1","2","3","4"],minimumLevel:3,maximumLevel:18,credit:"© 高德地图"})}async function C(u,e,t={longitude:120.2052342,latitude:30.2489634,height:1e3,pitch:-60,heading:0}){m.Ion.defaultAccessToken="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3M2M3NWU1Ni0xZmJkLTRkNjAtOTk4NC0wZDZhNWFiOWJlZDEiLCJpZCI6MzMxNTg1LCJpYXQiOjE3NTUyMjQ2MzB9.WBUG7ctHKtOrnay1ng8JNfaNgngbkNgOmRXP59OJ7ME";const i=new m.Viewer(u,{timeline:!1,animation:!1,baseLayerPicker:!1,...e});return!e.terrainProvider&&!e.terrain&&(i.terrainProvider=await m.createWorldTerrainAsync()),e.mapType==="gaode"&&(i.imageryLayers.removeAll(),i.imageryLayers.addImageryProvider(w())),t&&i.camera.flyTo({destination:n.Cartesian3.fromDegrees(t.longitude,t.latitude,t.height),orientation:{heading:n.Math.toRadians(t.heading||0),pitch:n.Math.toRadians(t.pitch||-30)}}),i.cesiumWidget.creditContainer.style.display="none",{viewer:i,initialCenter:t}}const v={CesiumMapToolbar:f,DrawHelper:g,initCesium:C};d.CesiumMapToolbar=f,d.DrawHelper=g,d.default=v,d.initCesium=C,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
124
134
  //# sourceMappingURL=index.umd.js.map