| | |
| | | /** |
| | | * |
| | | * SmartEarthSDK 基于UE的三维web开发 |
| | | * @author 张丹钊 |
| | | */ |
| | | !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).SmartEarth={})}(this,function(t){"use strict";function o(t,e){this.win=t,this.ue=e}function e(t,e){this.win=t,this.ue=e,this._core=new o(this.win,this.ue)}function n(e=8,o=16){var i="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),n=[];if(o=o||i.length,e)for(let t=0;t<e;t++)n[t]=i[0|Math.random()*o];else{n[8]=n[13]=n[18]=n[23]="-",n[14]="4";for(let t=0,e;t<36;t++)n[t]||(e=0|16*Math.random(),n[t]=i[19==t?3&e|8:e])}return n.join("")}function i(t,e){this.win=t,this.ue=e,this._core=new o(this.win,this.ue)}function a(t,e){i.call(this,t,e),this.win=t,this.ue=e}function s(t,e){i.call(this,t,e),this.win=t,this.ue=e}function r(t,e){i.call(this,t,e),this.win=t,this.ue=e}function c(t,e){i.call(this,t,e),this.win=t,this.ue=e,this._core=new o(this.win,this.ue),this._effects=!1,this._color="#ffffff"}function l(t,e){i.call(this,t,e),this.win=t,this.ue=e,this._core=new o(this.win,this.ue)}function u(t,e){i.call(this,t,e),this.win=t,this.ue=e}function h(t,e){i.call(this,t,e),this.win=t,this.ue=e}function p(t,e){i.call(this,t,e),this.win=t,this.ue=e}function f(t,e){this.win=t,this.ue=e,this._core=new o(this.win,this.ue)}o.prototype.defaultValue=function(t,e){return null!=t?t:e},o.prototype.createRandomId=function(){return(1e7*Math.random()).toString(16).substr(0,4)+"-"+(new Date).getTime()+"-"+Math.random().toString().substr(2,5)},o.prototype.getHeatmapData=function(e,o,i=600){var n=[];for(let t=0;t<i;t++){var a=Math.random()*(e.east-e.west)+e.west,s=Math.random()*(e.north-e.south)+e.south,r=o.value||Math.random()*(o.max-o.min)+o.min;n.push({x:a,y:s,value:r})}return n},o.prototype.getPositionFromWKT=function(t){t+="!";let a,s=[];return-1<t.indexOf("MULTIPOLYGON")?(a=(a=(a=t.replace("MULTIPOLYGON(","")).replace(")!","")).split(")),((")).forEach((t,e)=>{let n;(n=(n=1===a.length?t.substring(1,t.length-1):0===e?t.substring(1,t.length)+")":e===a.length-1?"("+t.substring(0,t.length-1):"("+t+")").split("),(")).forEach((t,e)=>{let o,i=(1===n.length?o=t.substring(1,t.length-1):0===e?o=t.substring(1,t.length):e===n.length-1&&(o=t.substring(0,t.length-1)),o=o.split(","),[]);o.forEach(t=>{t=t.split(" ");i.push({x:t[0],y:t[1],z:t[2]})}),s.push(i)})}):-1<t.indexOf("POLYGON")&&(a=(a=(a=t.replace("POLYGON(","")).replace(")!","")).split("),(")).forEach((t,e)=>{let o,i=(1===a.length?o=t.substring(1,t.length-1):0===e?o=t.substring(1,t.length):e===a.length-1&&(o=t.substring(0,t.length-1)),o=o.split(","),[]);o.forEach(t=>{t=t.split(" ");i.push({x:t[0],y:t[1],z:t[2]})}),s.push(i)}),s},o.prototype.postMessage=function(t){this.win?this.win.postMessage(t,"*"):this.ue&&this.ue("default",t)},e.prototype.createIndoormode=function(t=100){console.log("开启漫游模式,按Esc键退出"),this._core.postMessage({func_name:"setMoveMode",mode:1,speed:t}),document.onkeydown=t=>{"Escape"===t.key&&(this._core.postMessage({func_name:"setMoveMode",mode:0}),document.onkeydown=void 0,console.log("退出漫游模式"))}},e.prototype.closeIndoormode=function(){this._core.postMessage({func_name:"setMoveMode",mode:0}),document.onkeydown=void 0,console.log("退出漫游模式")},e.prototype.createWeather=function(t,e=!0){this._core.postMessage({func_name:"setWeather",weather_type:e?t:"sun"})},e.prototype.setTime=function(t=9){this._core.postMessage({func_name:"setTime",time:t})},e.prototype.horizontalDistance=function(t=!0){this._core.postMessage({func_name:"getDistanceHorizontal",showForward:t})},e.prototype.spaceDistance=function(t=!0){this._core.postMessage({func_name:"getDistanceTortuous",showForward:t})},e.prototype.verticalHeight=function(t=!0){this._core.postMessage({func_name:"getDistanceHeight",showForward:t})},e.prototype.planeArea=function(t=!0){this._core.postMessage({func_name:"getAreaHorizontal",showForward:t})},e.prototype.clearMeasure=function(){this._core.postMessage({func_name:"clearMeasure"})},i.prototype.addObjectToMap=function(t={}){let e=t.id||t.url||n(),o=t.objectType,i=("Billboard"!==o&&"3DTiles"!==o&&"migrateLine"!==o&&(e=o+"-"+e),t.id=e,this);this._core.postMessage(t),this.item={id:t.id,type:o,show(t){i.showMapObject(o,e,t)},removeFromMap(){i.removeMapObject(o,e)}},t.func_name.includes("draw")&&(this.end=()=>{this._core.postMessage({func_name:"endCustomDraw",id:e})})},i.prototype.setVisibility=function(t){this.item&&this.item.show(t)},i.prototype.deleteObject=function(){this.item&&this.item.removeFromMap(),this.item=void 0},i.prototype.removeMapObject=function(t,e,o=!1){"Billboard"===t||"3DTiles"===t?this._core.postMessage({func_name:"remove"+t+"GIS",url:e,id:e}):this._core.postMessage({func_name:"destroyActor",id:o?t+"-":e,fuzzySearch:o})},i.prototype.showMapObject=function(t,e,o,i=!1){"Billboard"===t||"3DTiles"===t?this._core.postMessage({func_name:"show"+t+"GIS",id:e,show:o}):this._core.postMessage({func_name:"setActorHidden",id:i?t+"-":e,hidden:!o,fuzzySearch:i,no_collision:!o})},i.prototype.showMapLayer=function(t,e){this._core.postMessage({func_name:"setLayerHidden",layer:t,hidden:!e})},i.prototype.getObject=function(t){this._core.postMessage({func_name:"getActorBasicInformation",id:t})},i.prototype.setHighlight=function(t,e=!1,o=!1){this._core.postMessage({func_name:"setActorHighLight",id:t,highlight:e,fuzzySearch:o})},((a.prototype=new i).constructor=a).prototype.createBillboard=function(t={}){return t.func_name="createBillboardGIS",t.objectType="Billboard",t.x=t.lon,t.y=t.lat,t.z=t.height,t.vectorType="WGS84",t.distanceDisplayCondition&&(t.distanceDisplayCondition={x:t.distanceDisplayCondition.far||2e3,y:t.distanceDisplayCondition.near||0}),this.item=this.addObjectToMap(t),this},((s.prototype=new i).constructor=s).prototype.createPolygon=function(t={}){return void 0!==t.extrudedHeight?(t.func_name="setCustomVolume",t.points1=t.points,t.points2=t.points,delete t.points,t.height1=t.height,t.height2=t.extrudedHeight,delete t.height,delete t.extrudedHeight):t.func_name="setCustomCovers2D",t.objectType="polygon",t.coverColor=t.color,t.opacity=t.alpha,this.addObjectToMap(t),this},s.prototype.drawPolygon=function(t={}){return t.func_name="drawCustomCovers2D",t.objectType="polygon",t.coverColor=t.color,t.opacity=t.alpha,this.addObjectToMap(t),this},((r.prototype=new i).constructor=r).prototype.createPolyline=function(t={}){return t.func_name="setCustomLine",t.objectType="polyline",this.addObjectToMap(t),this},r.prototype.createMigrateLine=function(t={}){var e="migrateLine-"+(t.id||n()),o=t.layer,i=t.type;return delete t.layer,delete t.type,this.addObjectToMap({func_name:"AddMigrateLines",objectType:"migrateLine",id:e,type:i,layer:o,lines:[{...t,id:e,start_lon:t.start.x,start_lat:t.start.y,start_height:t.start.z,end_lon:t.end.x,end_lat:t.end.y,end_height:t.end.z,color_strength:t.strength}]}),this},r.prototype.drawPolyline=function(t={}){return t.func_name="drawCustomLine",t.objectType="polyline",this.addObjectToMap(t),this},((c.prototype=new i).constructor=c).prototype.create3DTilesets=function(t="",e,o={}){return o.func_name="add3DTilesGIS",o.objectType="3DTiles",this.url=e,this.addObjectToMap({name:t,url:e,view_follow:o.flyTo,...o}),this},c.prototype.setOffset=function(t={}){this._core.postMessage({func_name:"addOffset3DTilesGIS",url:this.url,...t})},Object.defineProperties(c.prototype,{effects:{get:function(){return this._effects},set:function(t){(this._effects=t)||"#ffffff"!==this.color?this._core.postMessage({func_name:"set3DTilesGISMaterial",url:this.url,type:0,color:this._color,highlight:this._effects,loopTime:4}):this._core.postMessage({func_name:"reset3DTilesGISMaterial",url:this.url,type:0})}},material:{get:function(){return this._color},set:function(t){this._color=t,this._effects||"#ffffff"!==this.color?this._core.postMessage({func_name:"set3DTilesGISMaterial",url:this.url,type:0,color:this._color,highlight:this._effects,loopTime:4}):this._core.postMessage({func_name:"reset3DTilesGISMaterial",url:this.url,type:0})}}}),((l.prototype=new i).constructor=l).prototype.createPointCould=function(t={}){return t.func_name="addLiDARPointCould",t.objectType="pointCould",t.colorSource=t.colorSource||"Data",this.type="pointCould",this.addObjectToMap(t),this},l.prototype.createGltf=function(t={}){return t.func_name="addGltfModel",t.objectType="gltf",this.type="gltf",this.addObjectToMap(t),this},l.prototype.setPosition=function(e={}){if(this.item){let t;switch(this.type){case"pointCould":t="setLiDARPointCouldLocation";break;case"gltf":t="setGltfModelLocation"}this._core.postMessage({func_name:t,id:this.item.id,...e})}},l.prototype.setRotation=function(e={}){if(this.item){let t;switch(this.type){case"pointCould":t="setLiDARPointCouldRotation";break;case"gltf":t="setGltfModelRotation"}this._core.postMessage({func_name:t,id:this.item.id,...e})}},l.prototype.getInfo=function(){if(this.item){let t;switch(this.type){case"pointCould":t="getLiDARPointCouldLocationAndRotation";break;case"gltf":t="getGltfModelLocationAndRotation"}this._core.postMessage({func_name:t,id:this.item.id})}},((u.prototype=new i).constructor=u).prototype.createWall=function(t={}){return t.func_name="setCustomWall",t.objectType="wall",this.addObjectToMap(t),this},((h.prototype=new i).constructor=h).prototype.createHistogram=function(t={}){return t.func_name="setHistogram3D",t.objectType="histogram",this.addObjectToMap(t),this},((p.prototype=new i).constructor=p).prototype.addHeatMap=function(t,e={}){e.func_name="AddThermodynamicChart",e.objectType="heatMap";var o=this.getHeatMapData(e);return delete e.sourceData,delete e.radius,delete e.minOpacity,delete e.maxOpacity,delete e.blur,delete e.gradient,this.addObjectToMap({name:t,...o,...e,opacity:e.alpha}),this},p.prototype.getHeatMapData=function(t){this.radius=this.defaultValue(t.radius,50),this.blur=this.defaultValue(t.blur,.85),this.minOpacity=this.defaultValue(t.minOpacity,.1),this.maxOpacity=this.defaultValue(t.maxOpacity,.8),this.gradient=this.defaultValue(t.gradient,{".3":"blue",".5":"green",".7":"yellow",".95":"red"});t=t.sourceData;let i=300,n=-300,a=300,s=-300,r=-1/0,c=1/0;t.forEach(function(t){var e=t.x,o=t.y;i=Math.min(e,i),a=Math.min(o,a),n=Math.max(e,n),s=Math.max(o,s),r=Math.max(t.value,r),c=Math.min(t.value,c)});var e=n-i,o=s-a;let l={xMin:i-e/10,yMin:a-o/10,xMax:n+e/10,yMax:s+o/10},u=parseInt(300/(l.xMax-l.xMin)*(l.yMax-l.yMin)),h=(this.heatmapInstance?this.heatmapInstance._renderer.canvas.setAttribute("style","width:300px;height:"+u+"px;"):((e=document.createElement("div")).setAttribute("style","width:300px;height:"+u+"px;display:none;"),document.body.appendChild(e),this.heatmapInstance=h337.create({container:e,maxOpacity:this.maxOpacity,minOpacity:this.minOpacity,blur:this.blur,radius:this.radius,gradient:this.gradient})),[]);return t.forEach(function(t){var e=(t.x-l.xMin)/(l.xMax-l.xMin)*300,o=(-(t.y-l.yMin)/(l.yMax-l.yMin)+1)*u,e={x:Math.round(e),y:Math.round(o),value:t.value};h.push(e)}),this.datas={max:r,min:c,data:h},this.heatmapInstance.setData(this.datas),this.heatmapcanvas=this.heatmapInstance._renderer.canvas,{leftUp:{lon:i,lat:s},rightBottom:{lon:n,lat:a},url:this.heatmapcanvas.toDataURL("image/png").substring(22)}},p.prototype.defaultValue=function(t,e){return null!=t?t:e},f.prototype.createBillboard=function(t){return this.Billboard.createBillboard(t)},f.prototype.createPolyline=function(t={}){return this.Polyline.createPolyline(t)},f.prototype.createMigrateLine=function(t){return this.Polyline.createMigrateLine(t)},f.prototype.drawPolyline=function(t={}){return this.Polyline.drawPolyline(t)},f.prototype.createPolygon=function(t){return this.Polygon.createPolygon(t)},f.prototype.drawPolygon=function(t={}){return this.Polygon.drawPolygon(t)},f.prototype.createWall=function(t){return this.Wall.createWall(t)},f.prototype.createHistogram=function(t={}){return this.Histogram.createHistogram(t)},f.prototype.create3DTilesets=function(t=0,e,o){return this.SE3DTiles.create3DTilesets("",e,{})},f.prototype.addHeatMap=function(t,e){return this.Heatmap.addHeatMap(t,e)},f.prototype.createPointCould=function(t){return this.Model.createPointCould(t)},f.prototype.createGltf=function(t){return this.Model.createGltf(t)},f.prototype.createUrlTemplateImageryProvider=function(t=0,e={}){e.url+="/tilemapresource.xml",this._core.postMessage({func_name:"setTileMapGIS",url:e.url,min_level:e.minimumLevel,max_level:e.maximumLevel})},f.prototype.createTerrain=function(t=0,e={}){e.url+="/layer.json",this._core.postMessage({func_name:"setTileElevationGIS",...e})},Object.defineProperties(f.prototype,{Billboard:{get:function(){return new a(this.win,this.ue)}},Polyline:{get:function(){return new r(this.win,this.ue)}},Polygon:{get:function(){return new s(this.win,this.ue)}},Wall:{get:function(){return new u(this.win,this.ue)}},Histogram:{get:function(){return new h(this.win,this.ue)}},SE3DTiles:{get:function(){return new c(this.win,this.ue)}},Model:{get:function(){return new l(this.win,this.ue)}},Heatmap:{get:function(){return new p(this.win,this.ue)}}});let d="undefined"!=typeof window?window:"undefined"!=typeof self?self:{},m=document.currentScript&&document.currentScript.src;if(!m)try{throw Error("获取当前文件路径")}catch(t){t.fileName?m=t.fileName:t.stack?m=(t.stack.match(/at\s+(.*?):\d+:\d+/)||["",""])[1]:t.sourceURL&&(m=t.sourceURL)}let y=(m=-1<m.indexOf("(")?m.split("(")[1]:m).indexOf("SmartEarth.js");y<0&&(y=m.indexOf("SmartEarth.min.js"));let g;function _(t,e){this.win=t,this.ue=e,this._core=new o(this.win,this.ue)}function M(t,e){this.win=t,this.ue=e,this._MapObject=new i(t,e)}g=y<0?(y=m.indexOf("Source/Main"),m.substring(0,y)+"Build/"):m.substring(0,y),d.SmartEarthRootUrl=g,d.logSmartEarthLog=()=>{var t=d.SmartEarth&&d.SmartEarth.VERSION,e=d.SmartEarth&&d.SmartEarth.COMPILETIME;setTimeout(console.log.bind(console,` |
| | | %c |
| | | SmartEarth |
| | | %c |
| | | 版 本 号:${t} |
| | | 编译时间:${e} |
| | | 授权信息:内部测试版本。 |
| | | 版权声明: SmartEarthSDK版权完全属于【合肥泰瑞数创科技有限公司】 |
| | | |
| | | `,"font:bold 50px 微软雅黑;color:#018aff;","color:#018aff;font-size:13px;font-family:微软雅黑"),0)},_.prototype.flyToPosition=function(t,e,o,i={}){i={yaw:this._core.defaultValue(i.heading,0),pitch:this._core.defaultValue(i.pitch,-88),roll:this._core.defaultValue(i.roll,0),time:this._core.defaultValue(i.time,3),distance:this._core.defaultValue(i.distance,.1)};this._core.postMessage({func_name:"setViewGIS",x:t,y:e,z:o,...i})},_.prototype.flyToById=function(t,e={}){this._core.postMessage({func_name:"setViewGIS",id:t,...e})},_.prototype.rotateCenter=function(t=360,e=5){this._core.postMessage({func_name:"rotateCenter",degrees:t,time:e})},_.prototype.getCameraInfo=function(t){this.cameraInfoCallBack=t,this._core.postMessage({func_name:"getCameraMsg"})},_.prototype.getCameraInfoCallBack=function(t){this.cameraInfoCallBack&&this.cameraInfoCallBack(t),this.cameraInfoCallBack=null},M.prototype.getObject=function(t,e){this.objectDataCallBack=e,this._MapObject.getObject(t)},M.prototype.getObjectCallBack=function(t){this.objectDataCallBack&&this.objectDataCallBack(t),this.objectDataCallBack=null},M.prototype.setHighlight=function(t,e=!1,o=!1){this._MapObject.setHighlight(t,e,o)},M.prototype.removeAll=function(t){this._MapObject.removeMapObject(t,"all",!0)},M.prototype.setVisibilityAll=function(t,e){this._MapObject.showMapObject(t,"all",e,!0)},M.prototype.setVisibility=function(t,e){this._MapObject.showMapObject(void 0,t,e)},M.prototype.setLayerVisibility=function(t,e){this._MapObject.showMapLayer(t,e)},M.prototype.setLevelVisibility=function(t,e){this._MapObject._core.postMessage({func_name:"SetCustomLevelHidden",levelName:t,hidden:!e})},M.prototype.deleteItem=function(t){this._MapObject.removeMapObject(void 0,t)};var w=setTimeout(()=>{w=void 0,logSmartEarthLog&&logSmartEarthLog()},1e4);function b(t,o={},e){this.callBackAll={},this.defaultCallback=()=>{},w&&(clearTimeout(w),w=void 0,logSmartEarthLog)&&logSmartEarthLog(),this.callBackAll.initScene=()=>{o.x&&o.y&&o.z&&(o.time=o.duration,this.Navigate.flyToPosition(o.x,o.y,o.z,o)),e&&e()};let i=this;var n;if("object"==typeof ue&&"object"==typeof ue.interface&&"function"==typeof(n=ue.interface).broadcast&&(ue.interface={},ue.interface.broadcast=function(t,e){void 0!==e?n.broadcast(t,JSON.stringify(e)):n.broadcast(t,"")},ue.interface.RegisterCloudResponse=function(t){i.callBack_UE(t)},i._ue=ue.interface.broadcast,setTimeout(()=>{i.callBackAll.initScene()})),!i.ue){let e=document.createElement("iframe");e.style.cssText=` |
| | | !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).SmartEarth={})}(this,function(t){"use strict";function o(t,e){this.win=t,this.ue=e}function e(t,e){this.win=t,this.ue=e,this._core=new o(this.win,this.ue)}function n(e=8,o=16){var i="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),n=[];if(o=o||i.length,e)for(let t=0;t<e;t++)n[t]=i[0|Math.random()*o];else{n[8]=n[13]=n[18]=n[23]="-",n[14]="4";for(let t=0,e;t<36;t++)n[t]||(e=0|16*Math.random(),n[t]=i[19==t?3&e|8:e])}return n.join("")}function i(t,e){this.win=t,this.ue=e,this._core=new o(this.win,this.ue)}function a(t,e){i.call(this,t,e),this.win=t,this.ue=e}function s(t,e){i.call(this,t,e),this.win=t,this.ue=e}function r(t,e){i.call(this,t,e),this.win=t,this.ue=e}function c(t,e){i.call(this,t,e),this.win=t,this.ue=e,this._core=new o(this.win,this.ue),this._effects=!1,this._color="#ffffff"}function l(t,e){i.call(this,t,e),this.win=t,this.ue=e,this._core=new o(this.win,this.ue)}function u(t,e){i.call(this,t,e),this.win=t,this.ue=e}function h(t,e){i.call(this,t,e),this.win=t,this.ue=e}function p(t,e){i.call(this,t,e),this.win=t,this.ue=e}function f(t,e){this.win=t,this.ue=e,this._core=new o(this.win,this.ue)}o.prototype.defaultValue=function(t,e){return null!=t?t:e},o.prototype.createRandomId=function(){return(1e7*Math.random()).toString(16).substr(0,4)+"-"+(new Date).getTime()+"-"+Math.random().toString().substr(2,5)},o.prototype.getHeatmapData=function(e,o,i=600){var n=[];for(let t=0;t<i;t++){var a=Math.random()*(e.east-e.west)+e.west,s=Math.random()*(e.north-e.south)+e.south,r=o.value||Math.random()*(o.max-o.min)+o.min;n.push({x:a,y:s,value:r})}return n},o.prototype.getPositionFromWKT=function(t){t+="!";let a,s=[];return-1<t.indexOf("MULTIPOLYGON")?(a=(a=(a=t.replace("MULTIPOLYGON(","")).replace(")!","")).split(")),((")).forEach((t,e)=>{let n;(n=(n=1===a.length?t.substring(1,t.length-1):0===e?t.substring(1,t.length)+")":e===a.length-1?"("+t.substring(0,t.length-1):"("+t+")").split("),(")).forEach((t,e)=>{let o,i=(1===n.length?o=t.substring(1,t.length-1):0===e?o=t.substring(1,t.length):e===n.length-1&&(o=t.substring(0,t.length-1)),o=o.split(","),[]);o.forEach(t=>{t=t.split(" ");i.push({x:t[0],y:t[1],z:t[2]})}),s.push(i)})}):-1<t.indexOf("POLYGON")&&(a=(a=(a=t.replace("POLYGON(","")).replace(")!","")).split("),(")).forEach((t,e)=>{let o,i=(1===a.length?o=t.substring(1,t.length-1):0===e?o=t.substring(1,t.length):e===a.length-1&&(o=t.substring(0,t.length-1)),o=o.split(","),[]);o.forEach(t=>{t=t.split(" ");i.push({x:t[0],y:t[1],z:t[2]})}),s.push(i)}),s},o.prototype.postMessage=function(t){this.win?this.win.postMessage(t,"*"):this.ue&&this.ue("default",t)},e.prototype.createIndoormode=function(t=100){console.log("开启漫游模式,按Esc键退出"),this._core.postMessage({func_name:"setMoveMode",mode:1,speed:t}),document.onkeydown=t=>{"Escape"===t.key&&(this._core.postMessage({func_name:"setMoveMode",mode:0}),document.onkeydown=void 0,console.log("退出漫游模式"))}},e.prototype.closeIndoormode=function(){this._core.postMessage({func_name:"setMoveMode",mode:0}),document.onkeydown=void 0,console.log("退出漫游模式")},e.prototype.createWeather=function(t,e=!0){this._core.postMessage({func_name:"setWeather",weather_type:e?t:"sun"})},e.prototype.setTime=function(t=9){this._core.postMessage({func_name:"setTime",time:t})},e.prototype.horizontalDistance=function(t=!0){this._core.postMessage({func_name:"getDistanceHorizontal",showForward:t})},e.prototype.spaceDistance=function(t=!0){this._core.postMessage({func_name:"getDistanceTortuous",showForward:t})},e.prototype.verticalHeight=function(t=!0){this._core.postMessage({func_name:"getDistanceHeight",showForward:t})},e.prototype.planeArea=function(t=!0){this._core.postMessage({func_name:"getAreaHorizontal",showForward:t})},e.prototype.clearMeasure=function(){this._core.postMessage({func_name:"clearMeasure"})},i.prototype.addObjectToMap=function(t={}){let e=t.id||t.url||n(),o=t.objectType,i=("Billboard"!==o&&"3DTiles"!==o&&"migrateLine"!==o&&(e=o+"-"+e),t.id=e,this);this._core.postMessage(t),this.item={id:t.id,type:o,show(t){i.showMapObject(o,e,t)},removeFromMap(){i.removeMapObject(o,e)}},t.func_name.includes("draw")&&(this.end=()=>{this._core.postMessage({func_name:"endCustomDraw",id:e})})},i.prototype.setVisibility=function(t){this.item&&this.item.show(t)},i.prototype.deleteObject=function(){this.item&&this.item.removeFromMap(),this.item=void 0},i.prototype.removeMapObject=function(t,e,o=!1){"Billboard"===t||"3DTiles"===t?this._core.postMessage({func_name:"remove"+t+"GIS",url:e,id:e}):this._core.postMessage({func_name:"destroyActor",id:o?t+"-":e,fuzzySearch:o})},i.prototype.showMapObject=function(t,e,o,i=!1){"Billboard"===t||"3DTiles"===t?this._core.postMessage({func_name:"show"+t+"GIS",id:e,show:o}):this._core.postMessage({func_name:"setActorHidden",id:i?t+"-":e,hidden:!o,fuzzySearch:i,no_collision:!o})},i.prototype.showMapLayer=function(t,e){this._core.postMessage({func_name:"setLayerHidden",layer:t,hidden:!e})},i.prototype.getObject=function(t){this._core.postMessage({func_name:"getActorBasicInformation",id:t})},i.prototype.setHighlight=function(t,e=!1,o=!1){this._core.postMessage({func_name:"setActorHighLight",id:t,highlight:e,fuzzySearch:o})},((a.prototype=new i).constructor=a).prototype.createBillboard=function(t={}){return t.func_name="createBillboardGIS",t.objectType="Billboard",t.x=t.lon,t.y=t.lat,t.z=t.height,t.vectorType="WGS84",t.distanceDisplayCondition&&(t.distanceDisplayCondition={x:t.distanceDisplayCondition.far||2e3,y:t.distanceDisplayCondition.near||0}),this.item=this.addObjectToMap(t),this},((s.prototype=new i).constructor=s).prototype.createPolygon=function(t={}){return void 0!==t.extrudedHeight?(t.func_name="setCustomVolume",t.points1=t.points,t.points2=t.points,delete t.points,t.height1=t.height,t.height2=t.extrudedHeight,delete t.height,delete t.extrudedHeight):t.func_name="setCustomCovers2D",t.objectType="polygon",t.coverColor=t.color,t.opacity=t.alpha,this.addObjectToMap(t),this},s.prototype.drawPolygon=function(t={}){return t.func_name="drawCustomCovers2D",t.objectType="polygon",t.coverColor=t.color,t.opacity=t.alpha,this.addObjectToMap(t),this},((r.prototype=new i).constructor=r).prototype.createPolyline=function(t={}){return t.func_name="setCustomLine",t.objectType="polyline",this.addObjectToMap(t),this},r.prototype.createMigrateLine=function(t={}){var e="migrateLine-"+(t.id||n()),o=t.layer,i=t.type;return delete t.layer,delete t.type,this.addObjectToMap({func_name:"AddMigrateLines",objectType:"migrateLine",id:e,type:i,layer:o,lines:[{...t,id:e,start_lon:t.start.x,start_lat:t.start.y,start_height:t.start.z,end_lon:t.end.x,end_lat:t.end.y,end_height:t.end.z,color_strength:t.strength}]}),this},r.prototype.drawPolyline=function(t={}){return t.func_name="drawCustomLine",t.objectType="polyline",this.addObjectToMap(t),this},((c.prototype=new i).constructor=c).prototype.create3DTilesets=function(t="",e,o={}){return o.func_name="add3DTilesGIS",o.objectType="3DTiles",this.url=e,this.addObjectToMap({name:t,url:e,view_follow:o.flyTo,...o}),this},c.prototype.setOffset=function(t={}){this._core.postMessage({func_name:"addOffset3DTilesGIS",url:this.url,...t})},Object.defineProperties(c.prototype,{effects:{get:function(){return this._effects},set:function(t){(this._effects=t)||"#ffffff"!==this.color?this._core.postMessage({func_name:"set3DTilesGISMaterial",url:this.url,type:0,color:this._color,highlight:this._effects,loopTime:4}):this._core.postMessage({func_name:"reset3DTilesGISMaterial",url:this.url,type:0})}},material:{get:function(){return this._color},set:function(t){this._color=t,this._effects||"#ffffff"!==this.color?this._core.postMessage({func_name:"set3DTilesGISMaterial",url:this.url,type:0,color:this._color,highlight:this._effects,loopTime:4}):this._core.postMessage({func_name:"reset3DTilesGISMaterial",url:this.url,type:0})}}}),((l.prototype=new i).constructor=l).prototype.createPointCould=function(t={}){return t.func_name="addLiDARPointCould",t.objectType="pointCould",t.colorSource=t.colorSource||"Data",this.type="pointCould",this.addObjectToMap(t),this},l.prototype.createGltf=function(t={}){return t.func_name="addGltfModel",t.objectType="gltf",this.type="gltf",this.addObjectToMap(t),this},l.prototype.setPosition=function(e={}){if(this.item){let t;switch(this.type){case"pointCould":t="setLiDARPointCouldLocation";break;case"gltf":t="setGltfModelLocation"}this._core.postMessage({func_name:t,id:this.item.id,...e})}},l.prototype.setRotation=function(e={}){if(this.item){let t;switch(this.type){case"pointCould":t="setLiDARPointCouldRotation";break;case"gltf":t="setGltfModelRotation"}this._core.postMessage({func_name:t,id:this.item.id,...e})}},l.prototype.getInfo=function(){if(this.item){let t;switch(this.type){case"pointCould":t="getLiDARPointCouldLocationAndRotation";break;case"gltf":t="getGltfModelLocationAndRotation"}this._core.postMessage({func_name:t,id:this.item.id})}},((u.prototype=new i).constructor=u).prototype.createWall=function(t={}){return t.func_name="setCustomWall",t.objectType="wall",this.addObjectToMap(t),this},((h.prototype=new i).constructor=h).prototype.createHistogram=function(t={}){return t.func_name="setHistogram3D",t.objectType="histogram",this.addObjectToMap(t),this},((p.prototype=new i).constructor=p).prototype.addHeatMap=function(t,e={}){e.func_name="AddThermodynamicChart",e.objectType="heatMap";var o=this.getHeatMapData(e);return delete e.sourceData,delete e.radius,delete e.minOpacity,delete e.maxOpacity,delete e.blur,delete e.gradient,this.addObjectToMap({name:t,...o,...e,opacity:e.alpha}),this},p.prototype.getHeatMapData=function(t){this.radius=this.defaultValue(t.radius,50),this.blur=this.defaultValue(t.blur,.85),this.minOpacity=this.defaultValue(t.minOpacity,.1),this.maxOpacity=this.defaultValue(t.maxOpacity,.8),this.gradient=this.defaultValue(t.gradient,{".3":"blue",".5":"green",".7":"yellow",".95":"red"});t=t.sourceData;let i=300,n=-300,a=300,s=-300,r=-1/0,c=1/0;t.forEach(function(t){var e=t.x,o=t.y;i=Math.min(e,i),a=Math.min(o,a),n=Math.max(e,n),s=Math.max(o,s),r=Math.max(t.value,r),c=Math.min(t.value,c)});var e=n-i,o=s-a;let l={xMin:i-e/10,yMin:a-o/10,xMax:n+e/10,yMax:s+o/10},u=parseInt(300/(l.xMax-l.xMin)*(l.yMax-l.yMin)),h=(this.heatmapInstance?this.heatmapInstance._renderer.canvas.setAttribute("style","width:300px;height:"+u+"px;"):((e=document.createElement("div")).setAttribute("style","width:300px;height:"+u+"px;display:none;"),document.body.appendChild(e),this.heatmapInstance=h337.create({container:e,maxOpacity:this.maxOpacity,minOpacity:this.minOpacity,blur:this.blur,radius:this.radius,gradient:this.gradient})),[]);return t.forEach(function(t){var e=(t.x-l.xMin)/(l.xMax-l.xMin)*300,o=(-(t.y-l.yMin)/(l.yMax-l.yMin)+1)*u,e={x:Math.round(e),y:Math.round(o),value:t.value};h.push(e)}),this.datas={max:r,min:c,data:h},this.heatmapInstance.setData(this.datas),this.heatmapcanvas=this.heatmapInstance._renderer.canvas,{leftUp:{lon:i,lat:s},rightBottom:{lon:n,lat:a},url:this.heatmapcanvas.toDataURL("image/png").substring(22)}},p.prototype.defaultValue=function(t,e){return null!=t?t:e},f.prototype.createBillboard=function(t){return this.Billboard.createBillboard(t)},f.prototype.createPolyline=function(t={}){return this.Polyline.createPolyline(t)},f.prototype.createMigrateLine=function(t){return this.Polyline.createMigrateLine(t)},f.prototype.drawPolyline=function(t={}){return this.Polyline.drawPolyline(t)},f.prototype.createPolygon=function(t){return this.Polygon.createPolygon(t)},f.prototype.drawPolygon=function(t={}){return this.Polygon.drawPolygon(t)},f.prototype.createWall=function(t){return this.Wall.createWall(t)},f.prototype.createHistogram=function(t={}){return this.Histogram.createHistogram(t)},f.prototype.create3DTilesets=function(t=0,e,o){return this.SE3DTiles.create3DTilesets("",e,{})},f.prototype.addHeatMap=function(t,e){return this.Heatmap.addHeatMap(t,e)},f.prototype.createPointCould=function(t){return this.Model.createPointCould(t)},f.prototype.createGltf=function(t){return this.Model.createGltf(t)},f.prototype.createUrlTemplateImageryProvider=function(t=0,e={}){e.url+="/tilemapresource.xml",this._core.postMessage({func_name:"setTileMapGIS",url:e.url,min_level:e.minimumLevel,max_level:e.maximumLevel})},f.prototype.createTerrain=function(t=0,e={}){e.url+="/layer.json",this._core.postMessage({func_name:"setTileElevationGIS",...e})},Object.defineProperties(f.prototype,{Billboard:{get:function(){return new a(this.win,this.ue)}},Polyline:{get:function(){return new r(this.win,this.ue)}},Polygon:{get:function(){return new s(this.win,this.ue)}},Wall:{get:function(){return new u(this.win,this.ue)}},Histogram:{get:function(){return new h(this.win,this.ue)}},SE3DTiles:{get:function(){return new c(this.win,this.ue)}},Model:{get:function(){return new l(this.win,this.ue)}},Heatmap:{get:function(){return new p(this.win,this.ue)}}});let d="undefined"!=typeof window?window:"undefined"!=typeof self?self:{},m=document.currentScript&&document.currentScript.src;if(!m)try{throw Error("获取当前文件路径")}catch(t){t.fileName?m=t.fileName:t.stack?m=(t.stack.match(/at\s+(.*?):\d+:\d+/)||["",""])[1]:t.sourceURL&&(m=t.sourceURL)}let y=(m=-1<m.indexOf("(")?m.split("(")[1]:m).indexOf("SmartEarth.js");y<0&&(y=m.indexOf("SmartEarth.min.js"));let g;function _(t,e){this.win=t,this.ue=e,this._core=new o(this.win,this.ue)}function M(t,e){this.win=t,this.ue=e,this._MapObject=new i(t,e)}g=y<0?(y=m.indexOf("Source/Main"),m.substring(0,y)+"Build/"):m.substring(0,y),d.SmartEarthRootUrl=g,d.logSmartEarthLog=()=>{var t=d.SmartEarth&&d.SmartEarth.VERSION,e=d.SmartEarth&&d.SmartEarth.COMPILETIME;setTimeout(console.log.bind(console,``,""),0)},_.prototype.flyToPosition=function(t,e,o,i={}){i={yaw:this._core.defaultValue(i.heading,0),pitch:this._core.defaultValue(i.pitch,-88),roll:this._core.defaultValue(i.roll,0),time:this._core.defaultValue(i.time,3),distance:this._core.defaultValue(i.distance,.1)};this._core.postMessage({func_name:"setViewGIS",x:t,y:e,z:o,...i})},_.prototype.flyToById=function(t,e={}){this._core.postMessage({func_name:"setViewGIS",id:t,...e})},_.prototype.rotateCenter=function(t=360,e=5){this._core.postMessage({func_name:"rotateCenter",degrees:t,time:e})},_.prototype.getCameraInfo=function(t){this.cameraInfoCallBack=t,this._core.postMessage({func_name:"getCameraMsg"})},_.prototype.getCameraInfoCallBack=function(t){this.cameraInfoCallBack&&this.cameraInfoCallBack(t),this.cameraInfoCallBack=null},M.prototype.getObject=function(t,e){this.objectDataCallBack=e,this._MapObject.getObject(t)},M.prototype.getObjectCallBack=function(t){this.objectDataCallBack&&this.objectDataCallBack(t),this.objectDataCallBack=null},M.prototype.setHighlight=function(t,e=!1,o=!1){this._MapObject.setHighlight(t,e,o)},M.prototype.removeAll=function(t){this._MapObject.removeMapObject(t,"all",!0)},M.prototype.setVisibilityAll=function(t,e){this._MapObject.showMapObject(t,"all",e,!0)},M.prototype.setVisibility=function(t,e){this._MapObject.showMapObject(void 0,t,e)},M.prototype.setLayerVisibility=function(t,e){this._MapObject.showMapLayer(t,e)},M.prototype.setLevelVisibility=function(t,e){this._MapObject._core.postMessage({func_name:"SetCustomLevelHidden",levelName:t,hidden:!e})},M.prototype.deleteItem=function(t){this._MapObject.removeMapObject(void 0,t)};var w=setTimeout(()=>{w=void 0,logSmartEarthLog&&logSmartEarthLog()},1e4);function b(t,o={},e){this.callBackAll={},this.defaultCallback=()=>{},w&&(clearTimeout(w),w=void 0,logSmartEarthLog)&&logSmartEarthLog(),this.callBackAll.initScene=()=>{o.x&&o.y&&o.z&&(o.time=o.duration,this.Navigate.flyToPosition(o.x,o.y,o.z,o)),e&&e()};let i=this;var n;if("object"==typeof ue&&"object"==typeof ue.interface&&"function"==typeof(n=ue.interface).broadcast&&(ue.interface={},ue.interface.broadcast=function(t,e){void 0!==e?n.broadcast(t,JSON.stringify(e)):n.broadcast(t,"")},ue.interface.RegisterCloudResponse=function(t){i.callBack_UE(t)},i._ue=ue.interface.broadcast,setTimeout(()=>{i.callBackAll.initScene()})),!i.ue){let e=document.createElement("iframe");e.style.cssText=` |
| | | width:100%; |
| | | height:100%; |
| | | border:none; |