supermap-2.5d.vue 104 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692
  1. <template>
  2. <div id="supermap3D" style="width: 100%; height: 100%;background: none;overflow-y: auto;">
  3. <div id="cesiumContainer" style="width: 100%; height: 100%;background: none;">
  4. <!--地图top 显示 开始-->
  5. <transition name="fade">
  6. <div class="map-tit" v-show="mapshow">
  7. <div class="top-tit">
  8. <i class="iconfont sj-icon-jkzx"></i>
  9. <span><img src="../assets/images/close.svg" @click="mapshow=false"/></span>
  10. </div>
  11. <div class="map-txt" v-html="bindPopupHtml">
  12. </div>
  13. <el-button size="mini" type="primary" class="sj-icon-btn" @click="openTvwall()" v-if="_click!=''">
  14. 查看
  15. </el-button>
  16. <div id="super2"/>
  17. </div>
  18. </transition>
  19. <!--地图top 显示 结束-->
  20. <!--地图开挖 显示 开始-->
  21. <div id="excavation" v-show="showExcavation" class="param-container tool-bar excavation-tool-bar" style="
  22. background-color:rgba(15, 35, 54, 0.83) !important;
  23. border: 1px solid #0f7caf !important;
  24. border-radius: 5px;box-shadow: 0px 0px 12px rgba(15,108,158,0.88);">
  25. <div class="dzt-operate">
  26. <label class="form-label">开挖深度(米) :</label>
  27. <input type="text" class="form-control" value="20" id="depth" style="height: 25px;">
  28. </div>
  29. <div class="dzt-operate" style="margin-top: 2%;">
  30. <label class="form-label">上移高度(米) :</label>
  31. <input type="text" class="form-control" value="300" id="moveHeight" style="height: 25px;">
  32. </div>
  33. <div style="display: flex;justify-content: end;margin-top: 2%;">
  34. <!-- <button id="automaticDig" class="button black" type="button">自动开挖</button>-->
  35. <button id="dig" class="button" type="button">确认</button>
  36. <button id="clear" class="button" type="button" style="margin-right: 0">清除</button>
  37. <button id="close" class="button" type="button" style="margin-right: 8px;left: 8px;" @click="closeExcavationAll()">关闭</button>
  38. </div>
  39. </div>
  40. <!--地图开挖 显示 结束-->
  41. <!--地图裁剪 显示 开始-->
  42. <div id="clipboxByEditor" v-if="showClipboxByEditor" class="param-container tool-bar">
  43. <div>
  44. <select style="width: 180px;" id="clipMode">
  45. <option value="clip_behind_all_plane">裁剪包围盒内</option>
  46. <option value="clip_behind_any_plane">裁剪包围盒外</option>
  47. </select>
  48. <button type="button" id="clearbox" class="button black" style="float: right;">清 除</button>
  49. </div>
  50. </div>
  51. <!--地图开挖 显示 结束-->
  52. <!--地图开挖分析 显示 开始-->
  53. <div id="excavationAnalyze" v-if="showExcavationAnalyze" class="param-container tool-bar">
  54. <div class="param-item">
  55. <b>开挖高程:</b>
  56. <input type="text" id="depth" value="5000" style="margin-left: 50px;">
  57. </div>
  58. <div class="param-item">
  59. <b>开挖面积(平方米):</b>
  60. <input type="text" id="cutarea" value="" style="margin-left: 10px;">
  61. </div>
  62. <div class="param-item">
  63. <b>开挖体积(立方米):</b>
  64. <input type="text" id="cutVolume" value="" style="margin-left: 10px;">
  65. </div>
  66. <div class="param-item">
  67. <b>填方面积(平方米):</b>
  68. <input type="text" id="fillarea" value="" style="margin-left: 10px;">
  69. </div>
  70. <div class="param-item">
  71. <b>填方体积(立方米):</b>
  72. <input type="text" id="fillVolume" value="" style="margin-left: 10px;">
  73. </div>
  74. <div class="param-item">
  75. <b>未填挖面积(平方米):</b>
  76. <input type="text" id="remainderArea" value="">
  77. </div>
  78. <div class="param-item" style="float: right;">
  79. <button type="button" id="filladd" class="button black">绘制</button>
  80. <button type="button" id="fillclear" class="button black">清除</button>
  81. </div>
  82. </div>
  83. <!--地图开挖分析 显示 结束-->
  84. <!--地图选择、框选 显示 开始-->
  85. <div id="boxSelection" v-if="showSoxSelection">
  86. <Form style="width: 280px;z-index: 10000;" class="tool-bar param-container" tabindex="0">
  87. <div style="margin-bottom:4px;">
  88. <input type="button" id="isSelection" class="button black"><span
  89. style="vertical-align: middle">框选(按下选择键开始框选)</span>
  90. <!-- <input type="checkbox" id="isCallInMoving" style="vertical-align: middle;margin-right: 10px;"><span-->
  91. <!-- style="vertical-align: middle">实时选择</span>-->
  92. </div>
  93. <!-- <label>选择模式</label>-->
  94. <!-- <select id="mode">-->
  95. <!-- <option value="1" selected>重置模式</option>-->
  96. <!-- <option value="2">并集模式</option>-->
  97. <!-- <option value="4">交集模式</option>-->
  98. <!-- <option value="8">减去模式</option>-->
  99. <!-- </select>-->
  100. </Form>
  101. </div>
  102. <!--地图选择、框选 显示 结束-->
  103. <div id="pipeBurstAnalysis" v-if="showPipeBurstAnalysis" class="param-container tool-bar">
  104. <select id="options" class="form-control">
  105. <option selected value="down">下游分析</option>
  106. <option value="up">上游分析</option>
  107. <option value="faclilities">上游关键设施查找</option>
  108. </select>
  109. <button id="excavation">选择分析管线</button>
  110. <button id="clear">清除结果</button>
  111. </div>
  112. </div>
  113. </div>
  114. </template>
  115. <script>
  116. import { getDeviceList, iconList, queryMap } from '@/api/components/supermap.js'
  117. import Cookies from 'js-cookie'
  118. import { getConfigKey } from '@/api/system/config'
  119. export default {
  120. name: 'supermap-2.5d',
  121. data() {
  122. return {
  123. showExcavation:false,//开挖图示
  124. showExcavationAnalyze:false,//填开挖分析图示
  125. showClipboxByEditor:false,//裁剪图示
  126. clipboxByEditorEntity:null,//裁剪图层实体
  127. clipboxByEditorEntityLayers:null,//裁剪图层实体
  128. editorBox:null,//裁剪图层
  129. handlerBox:null,//裁剪图层
  130. showSoxSelection:false,//选择、框选
  131. showPipeBurstAnalysis:false,//爆管分析
  132. boxSelectionTooltip:null,//选择、框选Tooltip
  133. boxSelectionObjects : {//选择、框选元素
  134. isCallInMoving: false,
  135. selectedObjs: {},
  136. mode: 1
  137. },
  138. selectedObjsList:[],//框选的数据
  139. checkedCities:[],//选择的图层
  140. bindPopupHtml: null,
  141. mapshow: false,
  142. openZt: false,
  143. superMapRootUrl: null,
  144. viewer: null,
  145. scene: null,
  146. handler: null,
  147. pick: null,
  148. markerboxEntity: [], //地图落点实体
  149. connectBoxEntity: null, //地图线实体
  150. connectBoxEntityMove: [], //地图线实体_移动
  151. graphicsBoxEntity: null, //地图面实体
  152. graphicsBoxEntityList: [], //地图面实体
  153. markerboxEntityRadius: [], //地图落点实体
  154. connectBoxEntityTwo: null, //地图线实体
  155. /*************************原地图属性*********************/
  156. isEditableLayers: false, //绘图控件
  157. selOptV: 2, // 贴地量算
  158. clampMode: 1, // 空间模式
  159. handlerDis: null, // 距离
  160. handlerArea: null, // 面积
  161. handlerHeight: null, // 高度
  162. handlerExcavation: null, // 开挖
  163. handlerExcavationAnalyze: null, // 填开挖分析
  164. handlerBoxSelection: null, // 选择
  165. isObtainLaAndLon: false,
  166. clipboxByEditorTooltip:null,//裁剪地图鼠标提示
  167. excavationAnalyzeTooltip:null,//填开挖分析鼠标提示
  168. excavationTooltip:null,//开挖地图鼠标提示
  169. /*************************原地图属性*********************/
  170. aac: null,
  171. queryParams: {
  172. name: null,
  173. mapData: null,
  174. mapName: null
  175. },
  176. showLayer: true,
  177. clickTime: new Date().getTime(),
  178. /*************************图层过滤属性*********************/
  179. layerList: [],
  180. dianshiqiang: null,
  181. longitude: null,
  182. latitude: null,
  183. userList: null,
  184. dataMap: {},
  185. dataNameMap: {},
  186. lonAndLat: {},
  187. mvtMap: {},
  188. queryList: {},
  189. vdivcesiumContainer: '',
  190. reportSource: '',
  191. eventStatusValue: '',
  192. cameraCode: '',
  193. cameraRadius: '',
  194. open_LifelineList_3D: [], //生命线图层控制图层
  195. open_LifelineList_2D: [], //生命线图层控制图层
  196. imageryProvider_hideList: [], //隐藏图层实体
  197. open_hideList: [], //隐藏图层实体
  198. openModel_hideList: [], //隐藏图层实体
  199. find_hideList: [], //隐藏图层实体
  200. findDisplayed_hideList: [], //隐藏图层实体
  201. /*************************图层过滤属性*********************/
  202. _click: null,
  203. _parameter: null,
  204. positioningEntity: null,
  205. guanxianLayers:[],
  206. }
  207. },
  208. watch: {},
  209. created() {
  210. },
  211. mounted() {
  212. this.showLayer = this.showLayer != undefined ? this.showLayer : false
  213. },
  214. props: {
  215. // showLayer: [Boolean],
  216. },
  217. methods: {
  218. queryMap(deptId) {
  219. queryMap(deptId).then(req => {
  220. req = req.sort(function(a, b) {
  221. return a.sort - b.sort
  222. })
  223. this.onload(req)
  224. }
  225. )
  226. },
  227. onload(supermapUrls) {
  228. let that = this
  229. const withinData = supermapUrls
  230. //1.添加地形数据
  231. that.viewer = new SuperMap3D.Viewer('cesiumContainer', {
  232. //创建地形服务提供者的实例,url为SuperMap iServer发布的TIN地形服务
  233. terrainProvider: new SuperMap3D.SuperMapTerrainProvider({
  234. url: that.superMapRootUrl + '/3D-sipingchangjing/rest/realspace/datas/dem@spyx4326',
  235. //isSct : false,//地形服务源自SuperMap iServer发布时需设置isSct为true
  236. invisibility: true
  237. }),
  238. infoBox: false,
  239. navigation: false
  240. }, {
  241. contextOptions: {
  242. msaaLevel: 4,
  243. requestWebgl2: true
  244. },
  245. orderIndependentTranslucency: false
  246. })
  247. that.scene = that.viewer.scene
  248. that.viewer._Widget._creditContainer.style.display = "none" // 去掉超图logo水印
  249. //2.添加SuperMap iServer发布的影像服务
  250. // withinData.push(
  251. // {
  252. // "searchValue": null,
  253. // "createBy": null,
  254. // "createTime": null,
  255. // "updateBy": null,
  256. // "updateTime": null,
  257. // "remark": null,
  258. // "params": {},
  259. // "pageNum": null,
  260. // "pageSize": null,
  261. // "id": 1,
  262. // "deptId": 365,
  263. // "name": "底图",
  264. // "note": "124.48751127336885,43.3790475087265",
  265. // "path": "/3D-sipingchangjing/rest/realspace/datas/siping_2m@spyx4326",
  266. // "mapId": null,
  267. // "visuId": 20,
  268. // "parentId": null,
  269. // "sort": 0,
  270. // "deptName": null,
  271. // "type": "addImagery",
  272. // "scale": "350000",
  273. // "coordinate": "124.48751127336885,43.3790475087265",
  274. // "parentName": null,
  275. // "menuName": null,
  276. // "menuId": null
  277. // }
  278. // );
  279. //
  280. that.addImageryProvider(withinData[0].path)
  281. let longitude = withinData[0].coordinate.split(',')[0]
  282. let latitude = withinData[0].coordinate.split(',')[1]
  283. let height = withinData[0].scale
  284. setTimeout(function() {
  285. for (let i = 1; i < withinData.length; i++) {
  286. setTimeout(() => {
  287. if (withinData[i].type == 'addImagery') {
  288. if(withinData[i].note == '图层过滤'){
  289. return
  290. }
  291. that.addImageryProvider(withinData[i].path)
  292. } else if (withinData[i].type == 'addVectorTilesMap') {
  293. that.addVectorTilesMap(withinData[i].path)
  294. } else if (withinData[i].type == 'open') {
  295. if(withinData[i].note == '图层过滤'){
  296. return
  297. }
  298. that.addOpen(withinData[i].sort, withinData[i].path)
  299. }else if (withinData[i].type == 'open_model') {
  300. if(withinData[i].note == '图层过滤'){
  301. return
  302. }
  303. that.addOpen_model(withinData[i].sort, withinData[i].path)
  304. } else if (withinData[i].type == 'find') {
  305. that.addFind(withinData[i].parentId, withinData[i].path)
  306. }else if (withinData[i].type == 'findDisplayed') {
  307. that.addFind(withinData[i].parentId, withinData[i].path)
  308. }
  309. }, 100 * i)
  310. }
  311. }, 2000)
  312. // 监听地图点击事件
  313. that.viewer.selectedEntityChanged.addEventListener(function(entity) {
  314. // 获取点击图层的属性值ids
  315. if (entity != undefined && entity.id != undefined && entity.primitive) {
  316. let ids = entity.primitive.getSelection();
  317. // 获取点击图层的属性
  318. let layer = entity.primitive;
  319. // 循环查找属性
  320. for (let i = 0; i < ids.length; i++) {
  321. // 根据id获取属性value值
  322. layer.getAttributesById(ids[i]).then(function (data) {
  323. // 具体属性查看data
  324. console.log("三维管线数据:"+JSON.stringify(data));
  325. if('y_id' in data&&'y_name' in data){
  326. that.$emit('getHeatingPipeByDataSetAndSmId', data.y_id, data.y_name);
  327. }else if('Y_id' in data&&'Y_name' in data){
  328. that.$emit('getHeatingPipeByDataSetAndSmId', data.Y_id, data.Y_name);
  329. }
  330. });
  331. }
  332. }
  333. });
  334. that.handler = new SuperMap3D.ScreenSpaceEventHandler(that.scene.canvas);
  335. // that.scene.open('http://116.142.80.12:8090/iserver/services/3D-GH_tiedong-2/rest/realspace',undefined,{
  336. // autoSetView : false //不自动定位
  337. // })
  338. // that.scene.open('http://116.142.80.12:8090/iserver/services/3D-huashengranqi/rest/realspace',undefined,{
  339. // autoSetView : true //不自动定位
  340. // })
  341. // that.scene.open('http://116.142.80.12:8090/iserver/services/3D-ganghuaranqi/rest/realspace',undefined,{
  342. // autoSetView : false //不自动定位
  343. // })
  344. // that.scene.open(' http://116.142.80.12:8090/iserver/services/3D-huashengranqi-2/rest/realspace',undefined,{
  345. // autoSetView : false //不自动定位
  346. // })
  347. // that.scene.open('http://116.142.80.12:8090/iserver/services/3D-PaiShui/rest/realspace',undefined,{
  348. // autoSetView : false //不自动定位
  349. // })
  350. // that.scene.open('http://116.142.80.12:8090/iserver/services/3D-reli_yici_erci_guanduan-2/rest/realspace',undefined,{
  351. // autoSetView : false //不自动定位
  352. // })
  353. // that.scene.open(that.superMapRootUrl + '/3D-TD_yiciwang/rest/realspace')
  354. // that.scene.open(that.superMapRootUrl + '/3D-TX_erciwang_xian/rest/realspace')
  355. // that.scene.open(that.superMapRootUrl + '/3D-TX_yiciwang/rest/realspace')
  356. // that.scene.open(that.superMapRootUrl + '/3D-TD_erciwang_xian/rest/realspace')
  357. that.flyTo(longitude, latitude, height)
  358. // that.viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(
  359. // Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK
  360. // );
  361. setTimeout(() => {
  362. // that.viewer.imageryLayers.addImageryProvider(new SuperMap3D.SuperMapImageryProvider({
  363. // url:that.superMapRootUrl + '/map-RLyicierci-2/rest/maps/TD_all@erci'
  364. // }));
  365. // that.viewer.imageryLayers.addImageryProvider(new SuperMap3D.SuperMapImageryProvider({
  366. // url:that.superMapRootUrl + '/map-RLyicierci-2/rest/maps/TX_all@erci'
  367. // }));
  368. // that.viewer.imageryLayers.addImageryProvider(new SuperMap3D.SuperMapImageryProvider({
  369. // url:that.superMapRootUrl + '/map-RLyicierci-2/rest/maps/TX_all@yici'
  370. // }));
  371. // that.viewer.imageryLayers.addImageryProvider(new SuperMap3D.SuperMapImageryProvider({
  372. // url:that.superMapRootUrl + '/map-RLyicierci-2/rest/maps/TD_all@yici'
  373. // }));
  374. //设置鼠标左键单击回调事件
  375. that.handler.setInputAction(function (e) {
  376. if (that.isObtainLaAndLon) {
  377. if (that.positioningEntity != null) {
  378. that.viewer.entities.remove(that.positioningEntity);
  379. }
  380. //首先移除之前添加的点
  381. // viewer.entities.removeAll();
  382. //获取点击位置笛卡尔坐标
  383. let position = that.scene.pickPosition(e.position);
  384. //将笛卡尔坐标转化为经纬度坐标
  385. let cartographic = SuperMap3D.Cartographic.fromCartesian(position);
  386. let longitude = SuperMap3D.Math.toDegrees(cartographic.longitude);
  387. let latitude = SuperMap3D.Math.toDegrees(cartographic.latitude);
  388. let height = cartographic.height;
  389. if (height < 0) {
  390. height = 0;
  391. }
  392. that.positioningEntity = that.viewer.entities.add({
  393. name: "",
  394. position: new SuperMap3D.Cartesian3.fromDegrees(longitude, latitude),
  395. billboard: {
  396. image: iconList['positioning'],
  397. width: 48,
  398. height: 48,
  399. heightReference: SuperMap3D.HeightReference.CLAMP_TO_GROUND,
  400. disableDepthTestDistance: Number.POSITIVE_INFINITY
  401. },
  402. })
  403. debugger
  404. that.$emit('setPositioning', longitude, latitude);
  405. }
  406. }, SuperMap3D.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
  407. },5000)
  408. },
  409. //初始化地图数据
  410. removeAllviewer(deptId, index) {
  411. if (index != -1) {
  412. $('#cesiumContainer').remove()
  413. $('#supermap3D').append(
  414. '<div id="cesiumContainer" style="width: 100%; height: 100%;background: none;" >\n' +
  415. ' </div>')
  416. }
  417. let that = this
  418. that.superMapInfo(deptId)
  419. },
  420. superMapInfo(index) {
  421. let deptId = index;
  422. getConfigKey('superMap.iServer').then(response => {
  423. this.superMapRootUrl = response.msg
  424. // this.queryMap(index)
  425. Cookies.set('superMap.iServer', response.msg)
  426. setTimeout(() =>
  427. this.queryVectorTilesMapList(deptId) //切换地图
  428. ,1000
  429. )
  430. })
  431. },
  432. // ***************************生命线---图层过滤 开始************************************************
  433. addLifelineOpen(checkedCities) {
  434. this.checkedCities=checkedCities
  435. var checkedCities_2D=[]
  436. var checkedCities_3D=[]
  437. let List_2 = this.open_LifelineList_2D.map(item => item.url)
  438. List_2.forEach(url => {
  439. if (!url) return; // 如果没有 URL,跳过当前迭代
  440. this.viewer.imageryLayers.remove(this.selectMapObj_2D(url));
  441. });
  442. this.open_LifelineList_2D = []
  443. this.checkedCities.forEach(urlList => {
  444. if (!urlList.length) return; // 如果没有 URL,跳过当前迭代
  445. //加载三维图层
  446. if(urlList[0]){
  447. if(!this.open_LifelineList_3D.some(item => item.url === urlList[0])){//查找已勾选的图层数组
  448. let obj = this.scene.open(this.superMapRootUrl + urlList[0],undefined,{
  449. autoSetView : false //不自动定位
  450. })
  451. this.open_LifelineList_3D.push({
  452. url: urlList[0],
  453. mapObj: obj
  454. })
  455. }else{
  456. SuperMap3D.when.all(this.selectMapObj_3D(urlList[0]), function (layers) {
  457. for (let layer of layers) {
  458. layer.visible = true;
  459. }
  460. });
  461. }
  462. checkedCities_3D.push(urlList[0])
  463. }
  464. //加载二维图层
  465. if(urlList[1]){
  466. let obj = this.viewer.imageryLayers.addImageryProvider(new SuperMap3D.SuperMapImageryProvider({
  467. url:this.superMapRootUrl + urlList[1]
  468. }));
  469. this.open_LifelineList_2D.push({
  470. url: urlList[1],
  471. mapObj: obj
  472. })
  473. checkedCities_2D.push(urlList[1])
  474. }
  475. });
  476. const urlsToRemove_2D = this.open_LifelineList_2D.map(item => item.url).filter(url => !checkedCities_2D.includes(url));//查找没勾选的图层数组2D
  477. const urlsToRemove_3D = this.open_LifelineList_3D.map(item => item.url).filter(url => !checkedCities_3D.includes(url));//查找没勾选的图层数组3D
  478. // 此方法参数 【1、显示的管线smid集合,2、该集合对应的管线地址】
  479. // checkedCities_3D.forEach(url => {
  480. // if (!url) return; // 如果没有 URL,跳过当前迭代
  481. // SuperMap3D.when.all(this.selectMapObj_3D(url), function (layers) {
  482. // for (let layer of layers) {
  483. // layer.setObjsVisible([2908,2907],true);
  484. // }
  485. // });
  486. // });
  487. urlsToRemove_3D.forEach(url => {
  488. if (!url) return; // 如果没有 URL,跳过当前迭代
  489. SuperMap3D.when.all(this.selectMapObj_3D(url), function (layers) {
  490. for (let layer of layers) {
  491. layer.visible = false;
  492. }
  493. });
  494. });
  495. urlsToRemove_2D.forEach(url => {
  496. if (!url) return; // 如果没有 URL,跳过当前迭代
  497. this.viewer.imageryLayers.remove(this.selectMapObj_2D(url));
  498. });
  499. console.log('选中的url_2D:', checkedCities_2D);
  500. console.log('选中的url_3D:', checkedCities_3D);
  501. console.log('移除的url_2D:', urlsToRemove_2D);
  502. console.log('移除的url_3D:', urlsToRemove_3D);
  503. console.log('加载的url_2D:', this.open_LifelineList_2D);
  504. console.log('加载的url_3D:', this.open_LifelineList_3D);
  505. },
  506. selectMapObj_2D(url) {
  507. const item = this.open_LifelineList_2D.find(item => item.url === url);
  508. let mapObj= item ? item.mapObj : null;
  509. return mapObj
  510. },
  511. selectMapObj_3D(url) {
  512. const item = this.open_LifelineList_3D.find(item => item.url === url);
  513. let mapObj= item ? item.mapObj : null;
  514. return mapObj
  515. },
  516. // ***************************生命线---图层过滤 结束************************************************
  517. // ***************************图层过滤 开始************************************************
  518. reload(list) {
  519. this.removeAllMvt()
  520. this.removeAllImageryProvider_hide()
  521. this.removeAllOpen_hide()
  522. this.removeAllOpenModel_hide()
  523. this.layerList = list
  524. let that = this
  525. for (let i = 0; i < this.layerList.length; i++) {
  526. let data = this.queryList.filter(item => item.id == this.layerList[i]) [0]
  527. if (data.type == 'addImagery') {
  528. let imageryProvider = that.addImageryProvider(data.path)
  529. that.imageryProvider_hideList.push(imageryProvider)
  530. } else if(data.type=='addVectorTilesMap'){
  531. for (let key in that.mvtMap) {
  532. if (data.id == key) {
  533. that.mvtMap[key].show = true
  534. let dat = this.queryList.filter(item => item.parentId == data.id)
  535. for (let j = 0; j < dat.length; j++) {
  536. let da = this.queryList.filter(item => item.parentId == dat[j].id)
  537. for (let k = 0; k < da.length; k++) {
  538. for (let dataNameMapKey in that.dataNameMap) {
  539. if (dataNameMapKey == da[k].id) {
  540. this.dataMap[da[k].parentId].then(function() {
  541. that.dataNameMap[dataNameMapKey].visible = true
  542. })
  543. }
  544. }
  545. }
  546. }
  547. }
  548. }
  549. } else if (data.type == 'open') {
  550. let open = that.addOpen_under(data.id, data.path)
  551. that.open_hideList.push(open)
  552. } else if (data.type == 'open_model') {
  553. let openModel = that.addOpen_model(data.id, data.path)
  554. that.openModel_hideList.push(openModel)
  555. } else if (data.type == 'find') {
  556. let find = that.addFind(data.id, data.path)
  557. that.find_hideList.push(find)
  558. } else if (data.type == 'findDisplayed') {
  559. let findDisplayed = that.addFindDisplayed(data.id, data.path)
  560. that.findDisplayed_hideList.push(findDisplayed)
  561. }
  562. }
  563. },
  564. removeAllMvt() {
  565. let that = this
  566. // 移除方法,暂存:this.viewer.scene.removeVectorTilesMap(this.mvtMap.name);
  567. for (let i = 0; i < this.queryList.length; i++) {
  568. let data = this.queryList[i]
  569. for (let key in that.mvtMap) {
  570. if (data.id == key) {
  571. that.mvtMap[key].show = false
  572. let dat = this.queryList.filter(item => item.parentId == data.id)
  573. for (let j = 0; j < dat.length; j++) {
  574. if (dat[j].parentId != null) {
  575. let da = this.queryList.filter(item => item.parentId == dat[j].id)
  576. for (let k = 0; k < da.length; k++) {
  577. for (let dataNameMapKey in that.dataNameMap) {
  578. this.dataMap[da[k].parentId].then(function() {
  579. that.dataNameMap[dataNameMapKey].visible = false
  580. })
  581. }
  582. }
  583. }
  584. }
  585. }
  586. }
  587. }
  588. },
  589. removeAllImageryProvider_hide() {
  590. let that = this
  591. if (that.imageryProvider_hideList != null && that.imageryProvider_hideList.length > 0) {
  592. for (let i = 0; i < that.imageryProvider_hideList.length; i++) {
  593. that.viewer.imageryLayers.remove(that.imageryProvider_hideList[i])
  594. }
  595. that.imageryProvider_hideList = []
  596. }
  597. },
  598. removeAllOpen_hide() {
  599. let that = this
  600. if (that.open_hideList != null && that.open_hideList.length > 0) {
  601. for (let i = 0; i < that.open_hideList.length; i++) {
  602. SuperMap3D.when.all(that.open_hideList[i], function (layers) {
  603. for (let layer of layers) {
  604. that.scene.layers.remove(layer.name);
  605. // layer.visible = false;
  606. }
  607. });
  608. }
  609. that.open_hideList = []
  610. }
  611. },
  612. removeAllOpenModel_hide() {
  613. let that = this
  614. if (that.openModel_hideList != null && that.openModel_hideList.length > 0) {
  615. for (let i = 0; i < that.openModel_hideList.length; i++) {
  616. SuperMap3D.when.all(that.openModel_hideList[i], function (layers) {
  617. const reversedLayers = [...layers].reverse();
  618. for (let layer of reversedLayers) {
  619. that.scene.layers.remove(layer.name);
  620. that.viewer.imageryLayers.remove(layer)
  621. }
  622. });
  623. }
  624. that.openModel_hideList = []
  625. }
  626. },
  627. addFindDisplayed(id, uri) {
  628. let that = this
  629. let data = that.queryList.filter(item => item.id == id)[0]
  630. that.dataMap[data.parentId].then(function(layers) {
  631. let obj = that.scene.layers.find(uri) //区县文字图层
  632. //加载后隐藏
  633. obj.visible = false
  634. // //关闭避让
  635. obj.isOverlapDisplayed = true
  636. that.dataNameMap[id] = obj
  637. return obj
  638. })
  639. },
  640. addFind(id, uri){
  641. let that = this;
  642. let data = that.queryList.filter(item => item.id === id)
  643. if(data.length === 0) {
  644. return;
  645. }
  646. that.dataMap[data[0].parentId].then(function(layers) {
  647. let obj = that.scene.layers.find(uri) //区县文字图层
  648. return obj
  649. })
  650. },
  651. addOpen_model(sort, uri) {
  652. let that = this
  653. // that.dataMap[sort] = that.scene.open(that.superMapRootUrl + uri)
  654. let obj = that.dataMap[sort] = that.scene.open(that.superMapRootUrl + uri,undefined,{
  655. autoSetView : false //不自动定位
  656. })
  657. //开始加载专题图等数据,8秒后开始执行
  658. setTimeout(function () {
  659. /**
  660. * @param dom ScreenSpaceEventHandler操作的dom节点,画的框会成为其子节点
  661. */
  662. function DrawRectHandler(dom) {
  663. let startPoint,
  664. self = this,
  665. isShiftAndLeftDown = false,
  666. handler = new SuperMap3D.ScreenSpaceEventHandler(dom),
  667. removalFunctions = [],
  668. rect = new Rect(dom)
  669. this.isDestroyed = false
  670. this.activeEvt = new SuperMap3D.Event()
  671. this.cancelEvt = new SuperMap3D.Event()
  672. this.movingEvt = new SuperMap3D.Event()
  673. this.drawEvt = new SuperMap3D.Event()
  674. // div框
  675. function Rect(parentDom) {
  676. this.rect = document.createElement('div')
  677. this.rect.style.visibility = 'hidden'
  678. parentDom.appendChild(this.rect)
  679. this.leftTopPoint = new SuperMap3D.Cartesian2()
  680. this.rightBottomPoint = new SuperMap3D.Cartesian2()
  681. Rect.prototype.setPosition = function (startPoint, endPosition) {
  682. let w = endPosition.x - startPoint.x
  683. let h = endPosition.y - startPoint.y
  684. let left, top, width, height
  685. if (w < 0) {
  686. left = endPosition.x
  687. width = -w
  688. } else {
  689. left = startPoint.x
  690. width = w
  691. }
  692. if (h < 0) {
  693. top = endPosition.y
  694. height = -h
  695. } else {
  696. top = startPoint.y
  697. height = h
  698. }
  699. this.leftTopPoint = new SuperMap3D.Cartesian2(left, top)
  700. this.rightBottomPoint = new SuperMap3D.Cartesian2(left + width, top + height)
  701. this.rect.style = `position:fixed;top:${top}px;left:${left}px;width:${width}px;height:${height}px;border:2px dashed #333;`
  702. this.setVisible(true)
  703. }
  704. Rect.prototype.setVisible = function (isVisible) {
  705. this.rect.style.visibility = isVisible ? 'visible' : 'hidden'
  706. }
  707. Rect.prototype.getRectPoint = function () {
  708. return {
  709. leftTopPoint: this.leftTopPoint,
  710. rightBottomPoint: this.rightBottomPoint
  711. }
  712. }
  713. Rect.prototype.destroy = function () {
  714. dom.removeChild(rect)
  715. this.rect = null
  716. }
  717. }
  718. // canvas框
  719. function RectCanvas(parentDom) {
  720. let canvas = document.createElement('canvas'),
  721. ctx = canvas.getContext('2d')
  722. this.canvas = canvas
  723. canvas.width = parentDom.clientWidth
  724. canvas.height = parentDom.clientHeight
  725. canvas.style = 'position:fixed;top:0;left:0;z-index:-1'
  726. parentDom.appendChild(canvas)
  727. this.leftTopPoint = new SuperMap3D.Cartesian2()
  728. this.rightBottomPoint = new SuperMap3D.Cartesian2()
  729. RectCanvas.prototype.setPosition = function (startPoint, endPosition) {
  730. let w = endPosition.x - startPoint.x
  731. let h = endPosition.y - startPoint.y
  732. let left, top, width, height
  733. if (w < 0) {
  734. left = endPosition.x
  735. width = -w
  736. } else {
  737. left = startPoint.x
  738. width = w
  739. }
  740. if (h < 0) {
  741. top = endPosition.y
  742. height = -h
  743. } else {
  744. top = startPoint.y
  745. height = h
  746. }
  747. this.leftTopPoint = new SuperMap3D.Cartesian2(left, top)
  748. this.rightBottomPoint = new SuperMap3D.Cartesian2(left + width, top + height)
  749. ctx.clearRect(0, 0, canvas.width, canvas.height)
  750. ctx.strokeRect(left, top, width, height)
  751. }
  752. RectCanvas.prototype.setVisible = function (isVisible) {
  753. if (isVisible) {
  754. canvas.style.zIndex = '999'
  755. } else {
  756. canvas.style.zIndex = '-1'
  757. }
  758. }
  759. RectCanvas.prototype.getRectPoint = function () {
  760. return {
  761. leftTopPoint: this.leftTopPoint,
  762. rightBottomPoint: this.rightBottomPoint
  763. }
  764. }
  765. RectCanvas.prototype.destroy = function () {
  766. dom.removeChild(canvas)
  767. ctx = null
  768. this.canvas = null
  769. }
  770. }
  771. // 开关相机控制
  772. function setCameraCtrl(isActive) {
  773. let cameraCtrl = that.scene.screenSpaceCameraController
  774. cameraCtrl.enableRotate = isActive
  775. cameraCtrl.enableTranslate = isActive
  776. cameraCtrl.enableZoom = isActive
  777. cameraCtrl.enableTilt = isActive
  778. cameraCtrl.enableLook = isActive
  779. }
  780. // 鼠标cursor控制
  781. function toggleCursorStyle(isActive) {
  782. if (isActive) {
  783. that.viewer.enableCursorStyle = false
  784. that.viewer._element.style.cursor = ''
  785. dom.style.cursor = 'default'
  786. } else {
  787. that.viewer.enableCursorStyle = true
  788. }
  789. }
  790. // 初始化事件处理
  791. function initEvent() {
  792. handler.setInputAction(function (e) {
  793. isShiftAndLeftDown = true
  794. startPoint = new SuperMap3D.Cartesian2(e.position.x, e.position.y)
  795. }, SuperMap3D.ScreenSpaceEventType.LEFT_DOWN, SuperMap3D.KeyboardEventModifier.SHIFT)
  796. // shift松开时,始终将rect隐藏
  797. let keyUpFunction = function (e) {
  798. self.cancelEvt.raiseEvent()
  799. if (e.key == 'Shift' && isShiftAndLeftDown && !self.isDestroyed) {
  800. isShiftAndLeftDown = false
  801. rect.setVisible(false)
  802. }
  803. }
  804. document.addEventListener('keyup', keyUpFunction)
  805. removalFunctions.push(function () {
  806. document.removeEventListener('keyup', keyUpFunction)
  807. })
  808. handler.setInputAction(function (e) {
  809. let endPosition = e.endPosition
  810. self.activeEvt.raiseEvent(endPosition)
  811. if (!isShiftAndLeftDown) return
  812. rect.setPosition(startPoint, endPosition)
  813. rect.setVisible(true)
  814. self.movingEvt.raiseEvent(rect.getRectPoint())
  815. }, SuperMap3D.ScreenSpaceEventType.MOUSE_MOVE, SuperMap3D.KeyboardEventModifier.SHIFT)
  816. handler.setInputAction(function (e) {
  817. isShiftAndLeftDown = false
  818. rect.setVisible(false)
  819. self.drawEvt.raiseEvent(rect.getRectPoint())
  820. }, SuperMap3D.ScreenSpaceEventType.LEFT_UP, SuperMap3D.KeyboardEventModifier.SHIFT)
  821. handler.setInputAction(function (e) {
  822. isShiftAndLeftDown = false
  823. rect.setVisible(false)
  824. }, SuperMap3D.ScreenSpaceEventType.LEFT_UP)
  825. }
  826. // 移除事件监听
  827. function removeEvent() {
  828. handler.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_DOWN, SuperMap3D.KeyboardEventModifier.SHIFT)
  829. handler.removeInputAction(SuperMap3D.ScreenSpaceEventType.MOUSE_MOVE, SuperMap3D.KeyboardEventModifier.SHIFT)
  830. handler.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_UP, SuperMap3D.KeyboardEventModifier.SHIFT)
  831. handler.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_UP)
  832. }
  833. DrawRectHandler.prototype.destroy = function () {
  834. if (this.isDestroyed) return
  835. setCameraCtrl(true)
  836. removeEvent()
  837. for (let i = 0, j = removalFunctions.length; i < j; i++) {
  838. removalFunctions[i]()
  839. }
  840. handler.destroy()
  841. rect.destroy()
  842. rect = null
  843. this.isDestroyed = true
  844. }
  845. DrawRectHandler.prototype.activate = function () {
  846. if (this.isDestroyed) return
  847. setCameraCtrl(false)
  848. toggleCursorStyle(true)
  849. initEvent()
  850. }
  851. DrawRectHandler.prototype.deactivate = function () {
  852. if (this.isDestroyed) return
  853. setCameraCtrl(true)
  854. toggleCursorStyle(false)
  855. removeEvent()
  856. }
  857. }
  858. new SuperMap3D.when(that.dataMap[sort], function (layers) {
  859. for (let layer of layers) {
  860. layer.selectColorType = 1
  861. that.selectedObjs[layer.name] = []
  862. that.resetIds[layer.name] = []
  863. }
  864. let drawRect = that.drawRect = new DrawRectHandler(document.body)
  865. // res为框的左上点与右下点的相对于给定dom节点的坐标
  866. drawRect.drawEvt.addEventListener(function (res) {
  867. for (let layer of layers) {
  868. layer.selectColorType = 1
  869. }
  870. that.tooltip = false
  871. let selectedColor = new SuperMap3D.Color(1, 0, 0, 1)
  872. that.scene.pickRect(res.leftTopPoint, res.rightBottomPoint)
  873. let objs = that.scene.getPickRectIDs()
  874. let selectedObjs = that.selectedObjs
  875. let resetIds = that.resetIds
  876. for (let k in selectedObjs) {
  877. if (selectedObjs[k].length > 0) {
  878. that.scene.layers.find(k).removeObjsColor(selectedObjs[k])
  879. }
  880. }
  881. if (that.kuangxuan) {
  882. for (let layer of layers) {
  883. let layerName = layer.name
  884. if (layerName === undefined) break
  885. let layerSlt = objs.find(e => e.layerName === layerName)
  886. let sltIds = (layerSlt && layerSlt.ids) || []
  887. resetIds[layerName] = selectedObjs[layerName]
  888. selectedObjs[layerName] = sltIds
  889. that.$parent.$refs.ldTk.FrameSelectedData(sltIds)
  890. that.$parent.$refs.ldTk.allLouDongDialog = true
  891. layer.setObjsColor(selectedObjs[layerName], selectedColor)
  892. }
  893. }
  894. })
  895. drawRect.movingEvt.addEventListener(function (res) {
  896. that.tooltip = true
  897. if (that.kuangxuan) {
  898. that.tooltipText = "松开鼠标左键以结束选择区域"
  899. for (let layer of layers) {
  900. layer.selectColorType = 1
  901. }
  902. that.scene.pickRect(res.leftTopPoint, res.rightBottomPoint)
  903. } else {
  904. that.tooltipText = "请点击框选"
  905. }
  906. })
  907. drawRect.activeEvt.addEventListener(function (position) {
  908. that.tooltip = true
  909. if (that.kuangxuan) {
  910. that.tooltipText = "松开鼠标左键以结束选择区域"
  911. } else {
  912. that.tooltipText = "请点击框选"
  913. }
  914. })
  915. drawRect.cancelEvt.addEventListener(function () {
  916. that.tooltip = false
  917. })
  918. let canvas = document.querySelector('div.cesium-widget canvas')
  919. canvas.setAttribute('tabindex', '0') // needed to put focus on the canvas
  920. canvas.focus()
  921. document.addEventListener('keydown', function (e) {
  922. if (e.key === 'Shift') {
  923. drawRect.activate()
  924. }
  925. })
  926. document.addEventListener('keyup', function (e) {
  927. if (e.key === 'Shift') {
  928. drawRect.deactivate()
  929. }
  930. })
  931. }, function () {
  932. // let title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?'
  933. // widget.showErrorPanel(title, undefined, e)
  934. }).then(function () {
  935. }, function (e) {
  936. console.log(e)
  937. })
  938. }, 3000);
  939. return obj
  940. },
  941. addOpen(id, uri) {
  942. let that = this;
  943. let obj = that.scene.open(that.superMapRootUrl + uri)
  944. new SuperMap3D.when(obj,function(layers){
  945. let height = -150;
  946. for (let index in layers){
  947. let layer = layers[index];
  948. layer.style3D.bottomAltitude = height+=200;
  949. }
  950. },function (){
  951. })
  952. that.dataMap[id] = obj
  953. return obj;
  954. },
  955. addOpen_under(id, uri) {
  956. let that = this;
  957. let obj = that.scene.open(that.superMapRootUrl + uri,undefined,{
  958. autoSetView : false //不自动定位
  959. })
  960. that.dataMap[id] = obj
  961. return obj;
  962. },
  963. addVectorTilesMap(uri) {
  964. let that = this
  965. that.scene.addVectorTilesMap({
  966. url: that.superMapRootUrl + uri,
  967. canvasWidth: 512,
  968. name: 'mvt_map3',
  969. viewer: that.viewer,
  970. show: true
  971. })
  972. },
  973. addImageryProvider(uri){
  974. let that = this;
  975. let obj = that.viewer.imageryLayers.addImageryProvider(new SuperMap3D.SuperMapImageryProvider({
  976. url:that.superMapRootUrl + uri
  977. }));
  978. return obj;
  979. },
  980. // ************************************************************************图层过滤 结束***********************************************************************************
  981. // 清除测距、测面、测高
  982. closeMeasuringAll() {
  983. if (this.handlerDis != null) {
  984. this.handlerDis.clear()
  985. }
  986. if (this.handlerArea != null) {
  987. this.handlerArea.clear()
  988. }
  989. if (this.handlerHeight != null) {
  990. this.handlerHeight.clear()
  991. }
  992. },
  993. // 清除开挖,填开挖分析
  994. closeExcavationAll() {
  995. if(this.excavationTooltip){
  996. this.excavationTooltip.setVisible(false);
  997. }
  998. if (this.handlerExcavation != null) {
  999. this.handlerExcavation.deactivate();
  1000. this.handlerExcavation.clear();
  1001. this.viewer.scene.globe.removeAllExtractRegion();
  1002. this.handlerExcavation.activeEvt.addEventListener(function(isActive) {
  1003. if(isActive == true) {
  1004. this.viewer.enableCursorStyle = false;
  1005. this.viewer._element.style.cursor = '';
  1006. $('body').removeClass('drawCur').addClass('drawCur');
  1007. }
  1008. });
  1009. }
  1010. if (this.handlerExcavationAnalyze != null) {
  1011. this.viewer.scene.globe.removeAllModifyRegion();
  1012. document.getElementById("cutarea").value = "";
  1013. document.getElementById("cutVolume").value = "";
  1014. document.getElementById("fillarea").value = "";
  1015. document.getElementById("fillVolume").value = "";
  1016. document.getElementById("remainderArea").value = "";
  1017. this.handlerExcavationAnalyze.clear();
  1018. if(this.excavationAnalyzeTooltip){
  1019. this.excavationAnalyzeTooltip.setVisible(false);
  1020. }
  1021. }
  1022. this.showExcavation = false//开挖图示
  1023. this.showExcavationAnalyze = false//开挖分析图示
  1024. },
  1025. // 清除裁剪
  1026. closeClipboxByEditor() {
  1027. this.showClipboxByEditor=false
  1028. if(this.clipboxByEditorEntityLayers!= null){
  1029. for (var i = 0, j = this.clipboxByEditorEntityLayers.length; i < j; i++) {
  1030. this.clipboxByEditorEntityLayers[i].clearCustomClipBox();
  1031. this.scene.layers.remove(this.clipboxByEditorEntityLayers[i].name);
  1032. };
  1033. }
  1034. if(this.handlerBox!= null){
  1035. this.handlerBox.clear();
  1036. this.handlerBox.deactivate();
  1037. this.handlerBox = null;
  1038. }
  1039. if(this.editorBox!= null){
  1040. this.editorBox.deactivate();
  1041. this.editorBox = null;
  1042. }
  1043. this.viewer.entities.removeAll();
  1044. this.clipboxByEditorEntity=null
  1045. if(this.clipboxByEditorTooltip){
  1046. this.clipboxByEditorTooltip.setVisible(false);
  1047. }
  1048. },
  1049. // 测量距离
  1050. choseMeasuringDistance() {
  1051. let that = this
  1052. if (that.handlerDis != null) {
  1053. that.handlerDis.deactivate()
  1054. that.handlerDis.clear()
  1055. }
  1056. //初始化测量距离
  1057. that.handlerDis = new SuperMap3D.MeasureHandler(that.viewer, SuperMap3D.MeasureMode.Distance, that.clampMode)
  1058. that.handlerDis.clampMode = 1
  1059. //注册测距功能事件
  1060. that.handlerDis.measureEvt.addEventListener(function(result) {
  1061. let dis = Number(result.distance)
  1062. let selOptV = that.selOptV
  1063. if (selOptV == 3 || selOptV == 4) {
  1064. dis = Number(calcClampDistance(positions))
  1065. }
  1066. let distance = dis > 1000 ? (dis / 1000).toFixed(2) + 'km' : dis.toFixed(2) + 'm'
  1067. that.handlerDis.disLabel.text = '距离:' + distance
  1068. })
  1069. that.handlerDis.activeEvt.addEventListener(function(isActive) {
  1070. if (isActive == true) {
  1071. that.viewer.enableCursorStyle = false
  1072. that.viewer._element.style.cursor = ''
  1073. $('#super2').removeClass('measureCur').addClass('measureCur')
  1074. that.viewer.scene.pickPointEnabled = false
  1075. } else {
  1076. that.viewer.enableCursorStyle = true
  1077. $('#super2').removeClass('measureCur')
  1078. that.viewer.scene.pickPointEnabled = false
  1079. }
  1080. })
  1081. that.handlerDis.activate()
  1082. },
  1083. // 测量面积
  1084. choseMeasuringArea() {
  1085. let that = this
  1086. if (that.handlerArea != null) {
  1087. // that.handlerArea.deactivate()
  1088. that.handlerArea.clear()
  1089. }
  1090. //初始化测量面积
  1091. that.handlerArea = new SuperMap3D.MeasureHandler(that.viewer, SuperMap3D.MeasureMode.Area, that.clampMode)
  1092. that.handlerArea.clampMode = 1
  1093. that.handlerArea.measureEvt.addEventListener(function(result) {
  1094. let mj = Number(result.area)
  1095. let area = mj > 1000000 ? (mj / 1000000).toFixed(2) + 'km²' : mj.toFixed(2) + '㎡'
  1096. that.handlerArea.areaLabel.text = '面积:' + area
  1097. })
  1098. that.handlerArea.activeEvt.addEventListener(function(isActive) {
  1099. if (isActive == true) {
  1100. that.viewer.enableCursorStyle = false
  1101. that.viewer._element.style.cursor = ''
  1102. $('#super2').removeClass('measureCur').addClass('measureCur')
  1103. that.viewer.scene.pickPointEnabled = false
  1104. } else {
  1105. that.viewer.enableCursorStyle = true
  1106. that.viewer._element.style.cursor = ''
  1107. $('#super2').removeClass('measureCur')
  1108. that.viewer.scene.pickPointEnabled = false
  1109. }
  1110. })
  1111. that.handlerArea.activate()
  1112. },
  1113. // 测量高度
  1114. choseMeasuringHeight() {
  1115. let that = this
  1116. if (that.handlerHeight != null) {
  1117. // that.handlerHeight.deactivate()
  1118. that.handlerHeight.clear()
  1119. }
  1120. //初始化测量高度
  1121. that.handlerHeight = new SuperMap3D.MeasureHandler(that.viewer, SuperMap3D.MeasureMode.DVH);
  1122. that.handlerHeight.measureEvt.addEventListener(function (result) {
  1123. let distance = result.distance > 1000 ? (result.distance / 1000).toFixed(2) + 'km' : result.distance + 'm';
  1124. let vHeight = result.verticalHeight > 1000 ? (result.verticalHeight / 1000).toFixed(2) + 'km' : result.verticalHeight + 'm';
  1125. let hDistance = result.horizontalDistance > 1000 ? (result.horizontalDistance / 1000).toFixed(2) + 'km' : result.horizontalDistance + 'm';
  1126. that.handlerHeight.disLabel.text = '空间距离:' + distance;
  1127. that.handlerHeight.vLabel.text = '垂直高度:' + vHeight;
  1128. that.handlerHeight.hLabel.text = '水平距离:' + hDistance;
  1129. //实时等高线显示
  1130. lineHeight = Number(result.endHeight);
  1131. if (isShowLine) updateContourLine(lineHeight)
  1132. });
  1133. that.handlerHeight.activeEvt.addEventListener(function (isActive) {
  1134. if (isActive == true) {
  1135. that.viewer.enableCursorStyle = false;
  1136. that.viewer._element.style.cursor = '';
  1137. $('body').removeClass('measureCur').addClass('measureCur');
  1138. that.viewer.scene.pickPointEnabled = pickPointEnabled;
  1139. }
  1140. else {
  1141. that.viewer.enableCursorStyle = true;
  1142. $('body').removeClass('measureCur');
  1143. that.viewer.scene.pickPointEnabled = false;
  1144. }
  1145. });
  1146. that.handlerHeight.activate()
  1147. },
  1148. //开挖
  1149. excavation(showExcavation){
  1150. let that = this
  1151. that.showExcavation = showExcavation !== undefined ? showExcavation : true
  1152. if(!that.excavationTooltip){
  1153. that.excavationTooltip = createTooltip(document.body);
  1154. }
  1155. that.handlerExcavation = new SuperMap3D.DrawHandler(that.viewer, SuperMap3D.DrawMode.Polygon);
  1156. that.handlerExcavation.activeEvt.addEventListener(function(isActive) {
  1157. if(isActive == true) {
  1158. that.viewer.enableCursorStyle = false;
  1159. that.viewer._element.style.cursor = '';
  1160. $('body').removeClass('drawCur').addClass('drawCur');
  1161. } else {
  1162. that.viewer.enableCursorStyle = true;
  1163. $('body').removeClass('drawCur');
  1164. }
  1165. });
  1166. that.handlerExcavation.movingEvt.addEventListener(function(windowPosition) {
  1167. if(that.handlerExcavation.isDrawing) {
  1168. that.excavationTooltip.showAt(windowPosition, '<p>绘制多边形,</p><p>右键结束绘制.</p>');
  1169. } else {
  1170. that.excavationTooltip.showAt(windowPosition, '<p>点击绘制第一个点</p>');
  1171. }
  1172. });
  1173. that.handlerExcavation.drawEvt.addEventListener(function(res) {
  1174. that.handlerExcavation.clear();
  1175. that.handlerExcavation.deactivate();
  1176. that.excavationTooltip.setVisible(false);
  1177. setTimeout(function() {
  1178. let positions = [].concat(res.object.positions);
  1179. let positionsDegrees = [];
  1180. for(let i = 0; i < positions.length; i++) {
  1181. let cartographic = SuperMap3D.Cartographic.fromCartesian(positions[i]);
  1182. let lon = SuperMap3D.Math.toDegrees(cartographic.longitude);
  1183. let lat = SuperMap3D.Math.toDegrees(cartographic.latitude);
  1184. let h = cartographic.height;
  1185. positionsDegrees = positionsDegrees.concat([lon, lat, h]);
  1186. }
  1187. that.extract(positionsDegrees);
  1188. }, 2000)
  1189. })
  1190. //清除剖切结果
  1191. $('#clear').click(function() {
  1192. if(that.excavationTooltip) {
  1193. that.excavationTooltip.setVisible(false);
  1194. }
  1195. that.handlerExcavation.deactivate();
  1196. that.handlerExcavation.clear();
  1197. that.viewer.scene.globe.removeAllExtractRegion();
  1198. });
  1199. $("#dig").click(function() {
  1200. that.closeExcavationAll();
  1201. that.handlerExcavation.deactivate();
  1202. that.handlerExcavation.clear();
  1203. that.excavationTooltip.setVisible(false);
  1204. that.viewer.scene.globe.removeAllExtractRegion();
  1205. that.handlerExcavation.activate();
  1206. that.showExcavation=false
  1207. });
  1208. $("#automaticDig").click(function() {
  1209. that.automaticExcavationCalculation(124.3486419476308,43.168731902748924);
  1210. });
  1211. $('#loadingbar').remove();
  1212. },
  1213. //裁剪
  1214. clipboxByEditor(url){
  1215. let that = this
  1216. that.showClipboxByEditor=false
  1217. setTimeout(function() {
  1218. // 场景添加S3M图层服务
  1219. that.clipboxByEditorEntity = that.scene.open(that.superMapRootUrl + url,undefined,{
  1220. autoSetView : false //不自动定位
  1221. })
  1222. // try {
  1223. SuperMap3D.when(that.clipboxByEditorEntity, function (layers) {
  1224. that.clipboxByEditorEntityLayers=layers
  1225. // // 设置裁剪线颜色
  1226. // for (var i = 0, j = that.clipboxByEditorEntityLayers.length; i < j; i++) {
  1227. // that.clipboxByEditorEntityLayers[i].clipLineColor = new SuperMap3D.Color(1, 1, 1, 0);
  1228. // }
  1229. //
  1230. // var boxEntity = undefined;
  1231. // that.clipboxByEditorTooltip = createTooltip(document.body);
  1232. //
  1233. // function setAllLayersClipOptions(boxOptions) {
  1234. // for (var i = 0, j = that.clipboxByEditorEntityLayers.length; i < j; i++) {
  1235. // that.clipboxByEditorEntityLayers[i].setCustomClipBox(boxOptions);
  1236. // }
  1237. // }
  1238. //
  1239. // function setClipBox() {
  1240. // var clipMode = $('#clipMode').val();
  1241. // if (typeof (boxEntity) == "undefined") {
  1242. // return;
  1243. // }
  1244. // var newDim = boxEntity.box.dimensions.getValue();
  1245. // var position = boxEntity.position.getValue(0);
  1246. //
  1247. // var heading = 0;
  1248. // if (typeof (boxEntity.orientation) != "undefined") {
  1249. // let rotationM3 = SuperMap3D.Matrix3.fromQuaternion(boxEntity.orientation._value, new SuperMap3D.Matrix3());
  1250. // let localFrame = SuperMap3D.Matrix4.fromRotationTranslation(rotationM3, SuperMap3D.Cartesian3.ZERO, new SuperMap3D.Matrix4());
  1251. // let inverse = SuperMap3D.Matrix4.inverse(SuperMap3D.Transforms.eastNorthUpToFixedFrame(position), new SuperMap3D.Matrix4());
  1252. // let hprm = SuperMap3D.Matrix4.multiply(inverse, localFrame, new SuperMap3D.Matrix4());
  1253. // var rotation = SuperMap3D.Matrix4.getMatrix3(hprm, new SuperMap3D.Matrix3());
  1254. // let hpr = SuperMap3D.HeadingPitchRoll.fromQuaternion(SuperMap3D.Quaternion.fromRotationMatrix(rotation));
  1255. // heading = hpr.heading;
  1256. // }
  1257. //
  1258. //
  1259. // var boxOptions = {
  1260. // dimensions: newDim,
  1261. // position: position,
  1262. // clipMode: clipMode,
  1263. // heading: heading
  1264. // };
  1265. // setAllLayersClipOptions(boxOptions);
  1266. // }
  1267. //
  1268. // //交互绘制box
  1269. // that.handlerBox = new SuperMap3D.DrawHandler(that.viewer, SuperMap3D.DrawMode.Box);
  1270. // that.handlerBox.movingEvt.addEventListener(function (windowPosition) {
  1271. //
  1272. // if (that.handlerBox.isDrawing) {
  1273. // that.clipboxByEditorTooltip.showAt(windowPosition, '<p>点击鼠标左键结束矩形绘制,移动鼠标绘制box高度。</p><p>右键结束绘制.</p>');
  1274. // } else {
  1275. // that.clipboxByEditorTooltip.showAt(windowPosition, '<p>点击鼠标左键,开始绘制矩形作为box底面</p>');
  1276. // }
  1277. //
  1278. });
  1279. // that.handlerBox.drawEvt.addEventListener(function (e) {
  1280. // boxEntity = e.object;
  1281. // var newDim = boxEntity.box.dimensions.getValue();
  1282. // var position = boxEntity.position.getValue(0);
  1283. // var boxOption = {
  1284. // dimensions: newDim,
  1285. // position: position,
  1286. // clipMode: $('#clipMode').val(),
  1287. // heading: 0
  1288. // };
  1289. //
  1290. // //box编辑
  1291. // that.editorBox = new SuperMap3D.BoxEditor(that.viewer, boxEntity);
  1292. //
  1293. // that.editorBox.editEvt.addEventListener(function (e) {
  1294. // boxEntity.box.dimensions = e.dimensions
  1295. // boxEntity.position = e.position;
  1296. // boxEntity.orientation = e.orientation;
  1297. //
  1298. // setClipBox();
  1299. // });
  1300. // that.editorBox.distanceDisplayCondition = new SuperMap3D.DistanceDisplayCondition(0, 950);
  1301. // that.editorBox.activate();
  1302. // setAllLayersClipOptions(boxOption);
  1303. // that.clipboxByEditorTooltip.setVisible(false);
  1304. // that.handlerBox.clear();
  1305. // that.handlerBox.deactivate();
  1306. // });
  1307. //
  1308. // that.handlerBox.activate();
  1309. //
  1310. // $('#clearbox').click(function () {
  1311. // for (var i = 0, j = layers.length; i < j; i++) {
  1312. // layers[i].clearCustomClipBox();
  1313. // };
  1314. // that.editorBox.deactivate();
  1315. // that.viewer.entities.removeAll();
  1316. // that.handlerBox.clear();
  1317. // that.handlerBox.deactivate();
  1318. // that.handlerBox.activate();
  1319. //
  1320. // });
  1321. //
  1322. // $('#clipMode').change(function () {
  1323. // setClipBox();
  1324. // });
  1325. // }, function (e) {
  1326. // if (widget._showRenderLoopErrors) {
  1327. // var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?';
  1328. // widget.showErrorPanel(title, undefined, e);
  1329. // }
  1330. // });
  1331. // } catch (e) {
  1332. // if (widget._showRenderLoopErrors) {
  1333. // var title = '渲染时发生错误,已停止渲染。';
  1334. // widget.showErrorPanel(title, undefined, e);
  1335. // }
  1336. // }
  1337. // $('#toolbar').show();
  1338. // $('#loadingbar').remove();
  1339. }, 1000)
  1340. },
  1341. //自动挖选点
  1342. // automaticExcavation(){
  1343. // this.setIsObtainLaAndLon(true)
  1344. // },
  1345. //自动挖选计算
  1346. automaticExcavationCalculation(longitude, latitude) {
  1347. // 地球半径,单位:米
  1348. const EARTH_RADIUS = 6371000;
  1349. // 将经纬度转换为弧度
  1350. const latRad = latitude * Math.PI / 180;
  1351. const lonRad = longitude * Math.PI / 180;
  1352. // 矩形半边长,单位:米
  1353. const halfSide = 20;
  1354. // 计算经度和纬度的变化量(近似)
  1355. const dLat = halfSide / EARTH_RADIUS;
  1356. const dLon = halfSide / (EARTH_RADIUS * Math.cos(latRad));
  1357. // 将弧度转换回角度
  1358. const dLatDeg = dLat * 180 / Math.PI;
  1359. const dLonDeg = dLon * 180 / Math.PI;
  1360. const points = [
  1361. longitude - dLonDeg,
  1362. latitude + dLatDeg,
  1363. 0,
  1364. longitude + dLonDeg,
  1365. latitude + dLatDeg,
  1366. 0,
  1367. longitude + dLonDeg,
  1368. latitude - dLatDeg,
  1369. 0,
  1370. longitude - dLonDeg,
  1371. latitude - dLatDeg,
  1372. 0
  1373. ]
  1374. // // 计算四个角点的经纬度
  1375. // const points = {
  1376. // // 左上角
  1377. // topLeft: {
  1378. // latitude: latitude + dLatDeg,
  1379. // longitude: longitude - dLonDeg
  1380. // },
  1381. // // 右上角
  1382. // topRight: {
  1383. // latitude: latitude + dLatDeg,
  1384. // longitude: longitude + dLonDeg
  1385. // },
  1386. // // 左下角
  1387. // bottomLeft: {
  1388. // latitude: latitude - dLatDeg,
  1389. // longitude: longitude - dLonDeg
  1390. // },
  1391. // // 右下角
  1392. // bottomRight: {
  1393. // latitude: latitude - dLatDeg,
  1394. // longitude: longitude + dLonDeg
  1395. // }
  1396. // }
  1397. this.extract(points);
  1398. },
  1399. //根据点击点、长宽计算矩形四个顶点(以点击点为中心)
  1400. calculateRectangleVertices(centerPos, length, width) {
  1401. if (!centerPos) {
  1402. console.error('未获取到点击点坐标')
  1403. return null
  1404. }
  1405. // 矩形的半长和半宽(以中心为基准,向两侧偏移)
  1406. const halfLength = length / 2 // X轴方向长度(水平方向)
  1407. const halfWidth = width / 2 // Y轴方向宽度(垂直方向)
  1408. // 四个顶点坐标(笛卡尔坐标)
  1409. const vertices = [
  1410. // 左上角:X减半长,Y加半宽
  1411. new SuperMap3D.Cartesian3(
  1412. centerPos.x - halfLength,
  1413. centerPos.y + halfWidth,
  1414. centerPos.z // 高度与点击点一致
  1415. ),
  1416. // 右上角:X加半长,Y加半宽
  1417. new SuperMap3D.Cartesian3(
  1418. centerPos.x + halfLength,
  1419. centerPos.y + halfWidth,
  1420. centerPos.z
  1421. ),
  1422. // 右下角:X加半长,Y减半宽
  1423. new SuperMap3D.Cartesian3(
  1424. centerPos.x + halfLength,
  1425. centerPos.y - halfWidth,
  1426. centerPos.z
  1427. ),
  1428. // 左下角:X减半长,Y减半宽
  1429. new SuperMap3D.Cartesian3(
  1430. centerPos.x - halfLength,
  1431. centerPos.y - halfWidth,
  1432. centerPos.z
  1433. )
  1434. ]
  1435. return vertices
  1436. },
  1437. //地形抽出部分
  1438. extract(positions) {
  1439. let that = this
  1440. that.viewer.scene.globe.removeAllExtractRegion();
  1441. that.viewer.scene.globe.addExtractRegion({
  1442. name: 'extract', //名称
  1443. position: positions, //区域
  1444. height: $('#depth').val(), //开挖深度
  1445. transparent: false, //封边是否透明
  1446. extractHeight: Number($('#moveHeight').val()), //抽出高度
  1447. granularity: 1 //精度
  1448. })
  1449. },
  1450. //填开挖分析
  1451. excavationAnalyze(){
  1452. let that = this
  1453. that.showExcavationAnalyze=true
  1454. setTimeout(function() {
  1455. that.excavationAnalyzeTooltip = createTooltip(document.body);
  1456. that.handlerExcavationAnalyze = new SuperMap3D.DrawHandler(that.viewer, SuperMap3D.DrawMode.Polygon, that.clampMode);
  1457. that.handlerExcavationAnalyze.activeEvt.addEventListener(function (isActive) {
  1458. if (isActive == true) {
  1459. that.viewer.enableCursorStyle = false;
  1460. that.viewer._element.style.cursor = '';
  1461. $('body').removeClass('drawCur').addClass('drawCur');
  1462. } else {
  1463. that.viewer.enableCursorStyle = true;
  1464. $('body').removeClass('drawCur');
  1465. }
  1466. });
  1467. that.handlerExcavationAnalyze.movingEvt.addEventListener(function (windowPosition) {
  1468. if (that.handlerExcavationAnalyze.isDrawing) {
  1469. that.excavationAnalyzeTooltip.showAt(windowPosition, '<p>点击确定多边形中间点</p><p>右键单击结束绘制</p>');
  1470. } else {
  1471. that.excavationAnalyzeTooltip.showAt(windowPosition, '<p>点击绘制第一个点</p>');
  1472. }
  1473. });
  1474. that.handlerExcavationAnalyze.drawEvt.addEventListener(function (result) {
  1475. that.handlerExcavationAnalyze.polygon.show = false;
  1476. // that.handlerExcavationAnalyze.polyline.show = false;
  1477. that.handlerExcavationAnalyze.deactivate();
  1478. that.excavationAnalyzeTooltip.setVisible(false);
  1479. let dep = document.getElementById("depth").value;
  1480. let array = [].concat(result.object.positions);
  1481. let positions = [];
  1482. let positionsii = [];
  1483. for (let i = 0, len = array.length; i < len; i++) {
  1484. let cartographic = SuperMap3D.Cartographic.fromCartesian(array[i]);
  1485. let longitude = SuperMap3D.Math.toDegrees(cartographic.longitude);
  1486. let latitude = SuperMap3D.Math.toDegrees(cartographic.latitude);
  1487. let h = cartographic.height;
  1488. if (positions.indexOf(longitude) == -1 && positions.indexOf(latitude) == -1) {
  1489. positions.push(longitude);
  1490. positions.push(latitude);
  1491. positions.push(parseInt(dep));
  1492. positionsii.push({
  1493. x: longitude,
  1494. y: latitude
  1495. });
  1496. }
  1497. }
  1498. //此处用的地形修改 而不是地形开挖
  1499. that.viewer.scene.globe.removeAllModifyRegion();
  1500. that.viewer.scene.globe.addModifyRegion({
  1501. name: 'ggg',
  1502. position: positions
  1503. });
  1504. let length = [];
  1505. length.push(positionsii.length);
  1506. //需要在此 动态构造一个 REGION类型的对象
  1507. let geometry = {
  1508. "id": 23,
  1509. "parts": length,
  1510. "points": positionsii,
  1511. "style": null,
  1512. "type": "REGION"
  1513. };
  1514. let queryObj = {
  1515. "cutFillType": "REGIONANDALTITUDE",
  1516. "baseAltitude": dep,
  1517. "region": geometry,
  1518. "resultDataset": "result",
  1519. "buildPyramid": true,
  1520. "deleteExistResultDataset": true
  1521. };
  1522. let queryObjJSON = JSON.stringify(queryObj);
  1523. $.ajax({
  1524. type: 'post',
  1525. url: "http://www.supermapol.com/realspace/services/spatialAnalysis-dxyx_ios/restjsr/spatialanalyst/datasets/DEM@%E5%9B%9B%E5%A7%91%E5%A8%98%E5%B1%B1/terraincalculation/cutfill.json?returnContent=true",
  1526. data: queryObjJSON,
  1527. success: function (data) {
  1528. console.log(data);
  1529. // let resultObj = JSON.parse(data);
  1530. let resultObj = data;
  1531. document.getElementById("cutarea").value = resultObj.cutArea;
  1532. document.getElementById("cutVolume").value = resultObj.cutVolume;
  1533. document.getElementById("fillarea").value = resultObj.fillArea;
  1534. document.getElementById("fillVolume").value = resultObj.fillVolume;
  1535. document.getElementById("remainderArea").value = resultObj.remainderArea;
  1536. }
  1537. });
  1538. });
  1539. document.getElementById("filladd").onclick = function () {
  1540. that.handlerExcavationAnalyze.activate();
  1541. };
  1542. document.getElementById("fillclear").onclick = function () {
  1543. that.viewer.scene.globe.removeAllModifyRegion();
  1544. document.getElementById("cutarea").value = "";
  1545. document.getElementById("cutVolume").value = "";
  1546. document.getElementById("fillarea").value = "";
  1547. document.getElementById("fillVolume").value = "";
  1548. document.getElementById("remainderArea").value = "";
  1549. that.handlerExcavationAnalyze.clear();
  1550. };
  1551. $('#excavationAnalyze').show();
  1552. $('#loadingbar').remove();
  1553. if (!that.viewer.scene.pickPositionSupported) {
  1554. alert('不支持深度拾取,无法进行鼠标交互绘制!');
  1555. }
  1556. }, 1000)
  1557. },
  1558. //选择、框选
  1559. boxSelection(){
  1560. let that=this;
  1561. let layersAll = [];
  1562. that.checkedCities.forEach(urlList => {
  1563. if (!urlList.length) return; // 如果没有 URL,跳过当前迭代 // 如果没有 URL,跳过当前迭代
  1564. SuperMap3D.when.all(that.selectMapObj_3D(urlList[0]), function (layers) {
  1565. layersAll.push(layers)
  1566. if (layersAll.length === 0) {
  1567. return
  1568. }else{
  1569. that.showSoxSelection= true
  1570. /**
  1571. * @param dom ScreenSpaceEventHandler操作的dom节点,画的框会成为其子节点
  1572. */
  1573. function DrawRectHandler(dom) {
  1574. let startPoint,
  1575. self = this,
  1576. isShiftAndLeftDown = false,
  1577. removalFunctions = [],
  1578. rect = new Rect(dom)
  1579. that.handlerBoxSelection = new SuperMap3D.ScreenSpaceEventHandler(dom)
  1580. this.isDestroyed = false
  1581. this.activeEvt = new SuperMap3D.Event()
  1582. this.cancelEvt = new SuperMap3D.Event()
  1583. this.movingEvt = new SuperMap3D.Event()
  1584. this.drawEvt = new SuperMap3D.Event()
  1585. // div框
  1586. function Rect(parentDom) {
  1587. this.rect = document.createElement('div')
  1588. this.rect.style.visibility = 'hidden'
  1589. parentDom.appendChild(this.rect)
  1590. this.leftTopPoint = new SuperMap3D.Cartesian2()
  1591. this.rightBottomPoint = new SuperMap3D.Cartesian2()
  1592. Rect.prototype.setPosition = function (startPoint, endPosition) {
  1593. let w = endPosition.x - startPoint.x
  1594. let h = endPosition.y - startPoint.y
  1595. let left, top, width, height
  1596. if (w < 0) {
  1597. left = endPosition.x
  1598. width = -w
  1599. } else {
  1600. left = startPoint.x
  1601. width = w
  1602. }
  1603. if (h < 0) {
  1604. top = endPosition.y
  1605. height = -h
  1606. } else {
  1607. top = startPoint.y
  1608. height = h
  1609. }
  1610. this.leftTopPoint = new SuperMap3D.Cartesian2(left, top)
  1611. this.rightBottomPoint = new SuperMap3D.Cartesian2(left + width, top + height)
  1612. this.rect.style = `position:fixed;top:${top}px;left:${left}px;width:${width}px;height:${height}px;border:2px dashed #333;`
  1613. this.setVisible(true)
  1614. }
  1615. Rect.prototype.setVisible = function (isVisible) {
  1616. this.rect.style.visibility = isVisible ? 'visible' : 'hidden'
  1617. }
  1618. Rect.prototype.getRectPoint = function () {
  1619. return {
  1620. leftTopPoint: this.leftTopPoint,
  1621. rightBottomPoint: this.rightBottomPoint
  1622. }
  1623. }
  1624. Rect.prototype.destroy = function () {
  1625. dom.removeChild(rect)
  1626. this.rect = null
  1627. }
  1628. }
  1629. // canvas框
  1630. function RectCanvas(parentDom) {
  1631. let canvas = document.createElement('canvas'),
  1632. ctx = canvas.getContext('2d')
  1633. this.canvas = canvas
  1634. canvas.width = parentDom.clientWidth
  1635. canvas.height = parentDom.clientHeight
  1636. canvas.style = 'position:fixed;top:0;left:0;z-index:-1'
  1637. parentDom.appendChild(canvas)
  1638. this.leftTopPoint = new SuperMap3D.Cartesian2()
  1639. this.rightBottomPoint = new SuperMap3D.Cartesian2()
  1640. RectCanvas.prototype.setPosition = function (startPoint, endPosition) {
  1641. let w = endPosition.x - startPoint.x
  1642. let h = endPosition.y - startPoint.y
  1643. let left, top, width, height
  1644. if (w < 0) {
  1645. left = endPosition.x
  1646. width = -w
  1647. } else {
  1648. left = startPoint.x
  1649. width = w
  1650. }
  1651. if (h < 0) {
  1652. top = endPosition.y
  1653. height = -h
  1654. } else {
  1655. top = startPoint.y
  1656. height = h
  1657. }
  1658. this.leftTopPoint = new SuperMap3D.Cartesian2(left, top)
  1659. this.rightBottomPoint = new SuperMap3D.Cartesian2(left + width, top + height)
  1660. ctx.clearRect(0, 0, canvas.width, canvas.height)
  1661. ctx.strokeRect(left, top, width, height)
  1662. }
  1663. RectCanvas.prototype.setVisible = function (isVisible) {
  1664. if (isVisible) {
  1665. canvas.style.zIndex = '999'
  1666. } else {
  1667. canvas.style.zIndex = '-1'
  1668. }
  1669. }
  1670. RectCanvas.prototype.getRectPoint = function () {
  1671. return {
  1672. leftTopPoint: this.leftTopPoint,
  1673. rightBottomPoint: this.rightBottomPoint
  1674. }
  1675. }
  1676. RectCanvas.prototype.destroy = function () {
  1677. dom.removeChild(canvas)
  1678. ctx = null
  1679. this.canvas = null
  1680. }
  1681. }
  1682. // 开关相机控制
  1683. function setCameraCtrl(isActive) {
  1684. let cameraCtrl = that.scene.screenSpaceCameraController
  1685. cameraCtrl.enableRotate = isActive
  1686. cameraCtrl.enableTranslate = isActive
  1687. cameraCtrl.enableZoom = isActive
  1688. cameraCtrl.enableTilt = isActive
  1689. cameraCtrl.enableLook = isActive
  1690. }
  1691. // 鼠标cursor控制
  1692. function toggleCursorStyle(isActive) {
  1693. if (isActive) {
  1694. that.viewer.enableCursorStyle = false
  1695. that.viewer._element.style.cursor = ''
  1696. dom.style.cursor = 'default'
  1697. } else {
  1698. that.viewer.enableCursorStyle = true
  1699. }
  1700. }
  1701. // 初始化事件处理
  1702. function initEvent() {
  1703. that.handlerBoxSelection.setInputAction(function (e) {
  1704. isShiftAndLeftDown = true
  1705. startPoint = new SuperMap3D.Cartesian2(e.position.x, e.position.y)
  1706. }, SuperMap3D.ScreenSpaceEventType.LEFT_DOWN, SuperMap3D.KeyboardEventModifier.SHIFT)
  1707. // shift松开时,始终将rect隐藏
  1708. let keyUpFunction = function (e) {
  1709. self.cancelEvt.raiseEvent()
  1710. if (e.key == 'Shift' && isShiftAndLeftDown && !self.isDestroyed) {
  1711. isShiftAndLeftDown = false
  1712. rect.setVisible(false)
  1713. }
  1714. }
  1715. document.addEventListener('keyup', keyUpFunction)
  1716. removalFunctions.push(function () {
  1717. document.removeEventListener('keyup', keyUpFunction)
  1718. })
  1719. that.handlerBoxSelection.setInputAction(function (e) {
  1720. let endPosition = e.endPosition
  1721. self.activeEvt.raiseEvent(endPosition)
  1722. if (!isShiftAndLeftDown) return
  1723. rect.setPosition(startPoint, endPosition)
  1724. rect.setVisible(true)
  1725. self.movingEvt.raiseEvent(rect.getRectPoint())
  1726. }, SuperMap3D.ScreenSpaceEventType.MOUSE_MOVE, SuperMap3D.KeyboardEventModifier.SHIFT)
  1727. that.handlerBoxSelection.setInputAction(function (e) {
  1728. isShiftAndLeftDown = false
  1729. rect.setVisible(false)
  1730. self.drawEvt.raiseEvent(rect.getRectPoint())
  1731. }, SuperMap3D.ScreenSpaceEventType.LEFT_UP, SuperMap3D.KeyboardEventModifier.SHIFT)
  1732. that.handlerBoxSelection.setInputAction(function (e) {
  1733. isShiftAndLeftDown = false
  1734. rect.setVisible(false)
  1735. }, SuperMap3D.ScreenSpaceEventType.LEFT_UP)
  1736. }
  1737. // 移除事件监听
  1738. function removeEvent() {
  1739. that.handlerBoxSelection.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_DOWN, SuperMap3D.KeyboardEventModifier.SHIFT)
  1740. that.handlerBoxSelection.removeInputAction(SuperMap3D.ScreenSpaceEventType.MOUSE_MOVE, SuperMap3D.KeyboardEventModifier.SHIFT)
  1741. that.handlerBoxSelection.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_UP, SuperMap3D.KeyboardEventModifier.SHIFT)
  1742. that.handlerBoxSelection.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_UP)
  1743. }
  1744. DrawRectHandler.prototype.destroy = function () {
  1745. if (this.isDestroyed) return
  1746. setCameraCtrl(true)
  1747. removeEvent()
  1748. for (let i = 0, j = removalFunctions.length; i < j; i++) {
  1749. removalFunctions[i]()
  1750. }
  1751. that.handlerBoxSelection.destroy()
  1752. rect.destroy()
  1753. rect = null
  1754. this.isDestroyed = true
  1755. }
  1756. DrawRectHandler.prototype.activate = function () {
  1757. if (this.isDestroyed) return
  1758. setCameraCtrl(false)
  1759. toggleCursorStyle(true)
  1760. initEvent()
  1761. }
  1762. DrawRectHandler.prototype.deactivate = function () {
  1763. if (this.isDestroyed) return
  1764. setCameraCtrl(true)
  1765. toggleCursorStyle(false)
  1766. that.boxSelectionTooltip.setVisible(false)
  1767. removeEvent()
  1768. }
  1769. }
  1770. // div框
  1771. function Rect(parentDom) {
  1772. this.rect = document.createElement('div')
  1773. this.rect.style.visibility = 'hidden'
  1774. parentDom.appendChild(this.rect)
  1775. this.leftTopPoint = new SuperMap3D.Cartesian2()
  1776. this.rightBottomPoint = new SuperMap3D.Cartesian2()
  1777. Rect.prototype.setPosition = function (startPoint, endPosition) {
  1778. let w = endPosition.x - startPoint.x
  1779. let h = endPosition.y - startPoint.y
  1780. let left, top, width, height
  1781. if (w < 0) {
  1782. left = endPosition.x
  1783. width = -w
  1784. } else {
  1785. left = startPoint.x
  1786. width = w
  1787. }
  1788. if (h < 0) {
  1789. top = endPosition.y
  1790. height = -h
  1791. } else {
  1792. top = startPoint.y
  1793. height = h
  1794. }
  1795. this.leftTopPoint = new SuperMap3D.Cartesian2(left, top)
  1796. this.rightBottomPoint = new SuperMap3D.Cartesian2(left + width, top + height)
  1797. this.rect.style = `position:fixed;top:${top}px;left:${left}px;width:${width}px;height:${height}px;border:2px dashed #333;`
  1798. this.setVisible(true)
  1799. }
  1800. Rect.prototype.setVisible = function (isVisible) {
  1801. this.rect.style.visibility = isVisible ? 'visible' : 'hidden'
  1802. }
  1803. Rect.prototype.getRectPoint = function () {
  1804. return {
  1805. leftTopPoint: this.leftTopPoint,
  1806. rightBottomPoint: this.rightBottomPoint
  1807. }
  1808. }
  1809. Rect.prototype.destroy = function () {
  1810. dom.removeChild(rect)
  1811. this.rect = null
  1812. }
  1813. }
  1814. setTimeout(function() {
  1815. that.boxSelectionTooltip = createTooltip(document.body);
  1816. $('#loadingbar').remove();
  1817. for (let layers of layersAll) {
  1818. for (let layer of layers) {
  1819. layer.selectColorType = 1;
  1820. that.boxSelectionObjects.selectedObjs[layer.name] = [];
  1821. layer.indexedDBSetting.isAttributesSave = true;
  1822. }
  1823. }
  1824. let drawRect = new DrawRectHandler(document.body);
  1825. drawRect.drawEvt.addEventListener(function (res) {
  1826. that.boxSelectionTooltip.setVisible(false);
  1827. let selectedColor = new SuperMap3D.Color(1, 0, 0, 1);
  1828. that.scene.pickRect(res.leftTopPoint, res.rightBottomPoint);
  1829. that.scene.getPickRectIDsAsync().then(objs=>{
  1830. let selectedObjs = that.boxSelectionObjects.selectedObjs;
  1831. for (let k in selectedObjs) {
  1832. if (selectedObjs[k] !== undefined && selectedObjs[k] !== null && selectedObjs[k].length>0) {
  1833. that.scene.layers.find(k).removeObjsColor(selectedObjs[k]);
  1834. }
  1835. }
  1836. for (let layers of layersAll) {
  1837. for (let layer of layers) {
  1838. let layerName = layer.name;
  1839. let layerSlt = objs.find(e => e.layerName === layerName);
  1840. let sltIds = (layerSlt && layerSlt.ids) || [];
  1841. let lastIds = selectedObjs[layerName];
  1842. switch (that.boxSelectionObjects.mode) {
  1843. case 1:
  1844. selectedObjs[layerName] = sltIds;
  1845. break;
  1846. case 2:
  1847. selectedObjs[layerName] = _.union(lastIds, sltIds);;
  1848. break;
  1849. case 4:
  1850. selectedObjs[layerName] = _.intersection(lastIds, sltIds);
  1851. break;
  1852. case 8:
  1853. selectedObjs[layerName] = _.difference(lastIds, sltIds);
  1854. break;
  1855. default:
  1856. break;
  1857. }
  1858. layer.setObjsColor(selectedObjs[layerName], selectedColor);
  1859. that.processSelectedObjs(layer,selectedObjs[layerName])
  1860. }
  1861. setTimeout(() => {
  1862. console.log('选择的数据:'+JSON.stringify(selectedObjs))
  1863. console.log("三维管线数据:"+JSON.stringify(that.selectedObjsList));
  1864. that.$emit('getHeatingPipeListByDataSetAndSmId', that.selectedObjsList);
  1865. }, 2000)
  1866. }
  1867. });
  1868. });
  1869. drawRect.movingEvt.addEventListener(function (res) {
  1870. that.boxSelectionTooltip.showAt(res.rightBottomPoint,
  1871. '<p>松开鼠标左键以结束选择区域</p>'
  1872. );
  1873. if (that.boxSelectionObjects.isCallInMoving) {
  1874. for (let layer of layersAll) {
  1875. layer.selectColorType = 1;
  1876. }
  1877. that.scene.pickRect(res.leftTopPoint, res.rightBottomPoint);
  1878. }
  1879. });
  1880. drawRect.activeEvt.addEventListener(function (position) {
  1881. that.boxSelectionTooltip.showAt(position,
  1882. '<p>点击鼠标左键以开始选择区域</p>'
  1883. );
  1884. });
  1885. // $(document).keydown(function (e) {
  1886. // if (e.key === 'Shift') {
  1887. // drawRect.activate();
  1888. // }
  1889. // })
  1890. $(document).keyup(function (e) {
  1891. if (e.key === 'Shift') {
  1892. drawRect.deactivate();
  1893. }
  1894. })
  1895. $("#isCallInMoving").on("input change", function () {
  1896. that.boxSelectionObjects.isCallInMoving = that.checked;
  1897. });
  1898. $("#isSelection").click(function() {
  1899. drawRect.activate();
  1900. this.selectedObjsList = []
  1901. });
  1902. $("#mode").change(function (e) {
  1903. let mode = $("#mode").val();
  1904. that.boxSelectionObjects.mode = parseInt(mode);
  1905. });
  1906. }, 1000)
  1907. }
  1908. });
  1909. });
  1910. },
  1911. //框选数据处理
  1912. async processSelectedObjs(layer,selectedObjs) {
  1913. for(let i = 0; i < selectedObjs.length; i++) {
  1914. const data = await layer.getAttributesById(selectedObjs[i]);
  1915. this.selectedObjsList.push({'yId':data.y_id, 'yName':data.y_name});
  1916. console.log(selectedObjs[i]+" 数据:"+JSON.stringify(data));
  1917. }
  1918. },
  1919. //爆管分析
  1920. pipeBurstAnalysis(){
  1921. let that=this;
  1922. that.showPipeBurstAnalysis=true
  1923. // 开启地下模式
  1924. that.scene.undergroundMode = true
  1925. that.scene.screenSpaceCameraController.minimumZoomDistance = -1000
  1926. that.scene.globe.show = false
  1927. that.viewer.resolutionScale = window.devicePixelRatio;
  1928. // 添加地下管线模型
  1929. let promise_underground = that.scene.open('http://116.142.80.12:8090/iserver/services/3D-burstAnalysis/rest/realspace');
  1930. // setTimeout(()=>{
  1931. // new SuperMap3D.when(promise_underground, function (layers) {
  1932. // alert(layers)
  1933. // // 设置图层的LOD层级切换距离缩放系数。
  1934. // for (let layer of layers) {
  1935. // layer.lodRangeScale = 50
  1936. // }
  1937. //
  1938. // //查询所有阀门
  1939. // queryALLValve()
  1940. // //粒子特效
  1941. // let multiFireUrl = '../src/particle/fountain.json';
  1942. // modelMatrix = new SuperMap3D.Matrix4();
  1943. // let pos = new SuperMap3D.Cartesian3.fromDegrees(0, 0, 0)
  1944. // new SuperMap3D.Transforms.eastNorthUpToFixedFrame(pos, undefined, modelMatrix);
  1945. // new SuperMap3D.ParticleHelper.fromJsonUrl(multiFireUrl, that.scene).then(function (particleSys) {
  1946. // particleSystem = particleSys;
  1947. // particleSystem.emitRate = 200
  1948. // particleSystem.gravity = new SuperMap3D.Cartesian3(0, 0, 4)
  1949. // particleSystem.minLifeTime = 1
  1950. // particleSystem.maxLifeTime = 2
  1951. // particleSystem.minSize = 1
  1952. // particleSystem.maxSize = 4
  1953. // particleSystem.modelMatrix = modelMatrix;
  1954. // particleSystem.start();
  1955. // });
  1956. // // 获取管线管点图层
  1957. // pipeedge = that.scene.layers.find('PipeNetWork@Pipe3D#1')
  1958. // pipenode = that.scene.layers.find('PipeNetWork_Node@Pipe3D#1')
  1959. // pipenode1 = that.scene.layers.find('PipeNetWork_Node@Pipe3D')
  1960. // handler = new SuperMap3D.ScreenSpaceEventHandler(that.scene.canvas);
  1961. //
  1962. // // 开始分析按钮事件
  1963. // document.getElementById('excavation').onclick = () => {
  1964. // if (handler) {
  1965. //
  1966. // handler.setInputAction(function (e) {
  1967. // // 获取点击的管线ID
  1968. // pipesec = pipeedge.getSelection()
  1969. // if (!pipesec && pipesec.length === 0) {
  1970. // return
  1971. // }
  1972. // let position = that.scene.pickPosition(e.position)
  1973. // //爆管分析
  1974. // burstAnalysis(pipesec, position)
  1975. // }, SuperMap3D.ScreenSpaceEventType.LEFT_CLICK)
  1976. // }
  1977. // }
  1978. //
  1979. // // 清除按钮事件
  1980. // document.getElementById('clear').onclick = () => {
  1981. // if (handler) {
  1982. // handler.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_CLICK)
  1983. // }
  1984. // let pos = SuperMap3D.Cartesian3.fromDegrees(0, 0, 0)
  1985. // SuperMap3D.Transforms.eastNorthUpToFixedFrame(pos, undefined, modelMatrix);
  1986. // particleSystem.modelMatrix = modelMatrix;
  1987. // pipeedge.setObjsColor(edgeIds, SuperMap3D.Color.WHITE)
  1988. // pipenode.setObjsColor(nodeIds, SuperMap3D.Color.WHITE)
  1989. // pipenode1.setObjsColor(nodeIds, SuperMap3D.Color.WHITE)
  1990. //
  1991. // }
  1992. // })
  1993. // },1000)
  1994. if (!that.scene.pickPositionSupported) {
  1995. alert('不支持深度纹理,无法绘制多边形,地形开挖功能无法使用!');
  1996. }
  1997. $('#toolbar').show();
  1998. $('#loadingbar').remove();
  1999. /*
  2000. 爆管分析,pipesec:选取管线id,position:鼠标点击位置
  2001. */
  2002. function burstAnalysis(pipesec, position) {
  2003. SuperMap3D.Transforms.eastNorthUpToFixedFrame(position, undefined, modelMatrix);
  2004. particleSystem.modelMatrix = modelMatrix;
  2005. console.log(pipesec)
  2006. // 获取当前选择的分析方式
  2007. let value = document.getElementById('options').value
  2008. // 根据分析方式创建请求体
  2009. if (value === "down") {
  2010. workURL = 'http://116.142.80.12:8090/iserver/services/networkAnalyst3D-burstAnalysis-2/rest/facilityanalyst3d/PipeNetWork@Pipe3D/tracedownresult.json'
  2011. queryObj = {
  2012. edgeID: pipesec[0],
  2013. isUncertainDirectionValid: true,
  2014. weightName: 'WeightField'
  2015. }
  2016. } else if (value === 'up') {
  2017. workURL = 'http://116.142.80.12:8090/iserver/services/networkAnalyst3D-burstAnalysis-2/rest/facilityanalyst3d/PipeNetWork@Pipe3D/traceupresult.json'
  2018. queryObj = {
  2019. edgeID: pipesec[0],
  2020. isUncertainDirectionValid: true,
  2021. weightName: 'WeightField'
  2022. }
  2023. } else if (value === 'faclilities') {
  2024. let valve = valves
  2025. let ids = JSON.stringify(valve)
  2026. workURL = 'http://116.142.80.12:8090/iserver/services/networkAnalyst3D-burstAnalysis-2/rest/facilityanalyst3d/PipeNetWork@Pipe3D/upstreamcirticalfaclilities.json'
  2027. queryObj = {
  2028. sourceNodeIDs: ids,
  2029. edgeID: pipesec[0],
  2030. isUncertainDirectionValid: true
  2031. }
  2032. }
  2033. // 发送请求
  2034. $.ajax({
  2035. type: 'GET',
  2036. url: workURL,
  2037. data: queryObj,
  2038. success: data => {
  2039. // 得到结果
  2040. console.log(data)
  2041. if (data.edges) {
  2042. edgeIds = data.edges
  2043. pipeedge.setObjsColor(data.edges, SuperMap3D.Color.RED)
  2044. }
  2045. if (data.nodes) {
  2046. nodeIds = data.nodes
  2047. pipenode.setObjsColor(data.nodes, SuperMap3D.Color.RED)
  2048. pipenode1.setObjsColor(data.nodes, SuperMap3D.Color.RED)
  2049. }
  2050. },
  2051. error: res => {
  2052. console.log(res)
  2053. }
  2054. })
  2055. }
  2056. // 查询所有阀门
  2057. function queryALLValve() {
  2058. //查询阀门地址和参数
  2059. let dataServiceUrl = 'http://116.142.80.12:8090/iserver/services/data-burstAnalysis/rest/data/featureResults.json?returnContent=true';
  2060. let queryObj = {
  2061. getFeatureMode: 'SQL',
  2062. datasetNames: ['Pipe3D:PipeNetWork_Node'],
  2063. queryParameter: {
  2064. attributeFilter: "Name='阀门'"
  2065. }
  2066. };
  2067. queryObjJSON = JSON.stringify(queryObj); // 转化为JSON字符串作为查询参数
  2068. $.ajax({
  2069. type: "post",
  2070. url: dataServiceUrl,
  2071. data: queryObjJSON,
  2072. success: function (result) {
  2073. valves = []
  2074. result.features.map(function (element) {
  2075. // 遍历数组,对每个元素进行操作
  2076. valves.push(element.ID);
  2077. });
  2078. },
  2079. error: function (msg) {
  2080. console.log(msg);
  2081. }
  2082. })
  2083. }
  2084. },
  2085. //清除框选
  2086. removeBoxSelection(){
  2087. this.showSoxSelection= false
  2088. let selectedObjs = this.boxSelectionObjects.selectedObjs;
  2089. for (let k in selectedObjs) {
  2090. if (selectedObjs[k] !== undefined && selectedObjs[k] !== null && selectedObjs[k].length>0) {
  2091. this.scene.layers.find(k).removeObjsColor(selectedObjs[k]);
  2092. }
  2093. }
  2094. if(this.boxSelectionTooltip){
  2095. this.boxSelectionTooltip.setVisible(false);
  2096. }
  2097. if(this.handlerBoxSelection){
  2098. this.handlerBoxSelection.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_DOWN, SuperMap3D.KeyboardEventModifier.SHIFT)
  2099. this.handlerBoxSelection.removeInputAction(SuperMap3D.ScreenSpaceEventType.MOUSE_MOVE, SuperMap3D.KeyboardEventModifier.SHIFT)
  2100. this.handlerBoxSelection.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_UP, SuperMap3D.KeyboardEventModifier.SHIFT)
  2101. this.handlerBoxSelection.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_UP)
  2102. }
  2103. },
  2104. /**
  2105. * 切换地图
  2106. */
  2107. queryVectorTilesMapList(deptId) {
  2108. queryMap(deptId).then(req => { // from forestry_develop_2.0
  2109. //切换地图
  2110. req = req.sort(function(a, b) {
  2111. return a.sort - b.sort
  2112. })
  2113. this.queryList = req
  2114. this.onload(req)
  2115. })
  2116. },
  2117. //清除所有
  2118. clearAll() {
  2119. this.viewer.entities.removeAll()
  2120. this.viewer.scene.scanEffect.show = false
  2121. },
  2122. //移除之前添加的点
  2123. clearMRadius() {
  2124. if (this.markerboxEntityRadius != null && this.markerboxEntityRadius.length > 0) {
  2125. for (let i = 0; i < this.markerboxEntityRadius.length; i++) {
  2126. this.viewer.entities.remove(this.markerboxEntityRadius[i])
  2127. }
  2128. this.markerboxEntityRadius = []
  2129. }
  2130. },
  2131. //移除之前添加的线
  2132. clearTwoC() {
  2133. if (this.connectBoxEntityTwo != null) {
  2134. this.viewer.entities.remove(this.connectBoxEntityTwo)
  2135. this.connectBoxEntityTwo = null
  2136. }
  2137. },
  2138. //移除之前添加的线_移动
  2139. clearCM() {
  2140. if (this.connectBoxEntityMove != null && this.connectBoxEntityMove.length > 0) {
  2141. for (let i = 0; i < this.connectBoxEntityMove.length; i++) {
  2142. this.viewer.entities.remove(this.connectBoxEntityMove[i])
  2143. }
  2144. this.connectBoxEntityMove = []
  2145. }
  2146. },
  2147. /**
  2148. * 地图落点-覆盖范围
  2149. */
  2150. setMarkersRadius(makerList) {
  2151. let that = this
  2152. for (let i = 0; i < makerList.length; i++) {
  2153. let longitude = makerList[i].lng*1;
  2154. let latitude = makerList[i].lat*1;
  2155. let radius = makerList[i].radius*1;
  2156. let marker = that.viewer.entities.add({
  2157. name: "",
  2158. position: new SuperMap3D.Cartesian3.fromDegrees(longitude, latitude),
  2159. billboard: {
  2160. image: iconList[makerList[i].icon],
  2161. width: 48,
  2162. height: 48,
  2163. heightReference: SuperMap3D.HeightReference.CLAMP_TO_GROUND,
  2164. disableDepthTestDistance: Number.POSITIVE_INFINITY
  2165. },
  2166. description: makerList[i].bindPopupHtml,
  2167. click: makerList[i].click,
  2168. parameter: makerList[i].parameter
  2169. })
  2170. that.markerboxEntityRadius.push(marker)
  2171. //绘制摄像头的圈(覆盖范围)
  2172. // if(radius!=0){
  2173. // const markerRadius = that.viewer.entities.add({
  2174. // position: new SuperMap3D.Cartesian3.fromDegrees(longitude, latitude),
  2175. // ellipse: {
  2176. // semiMinorAxis: radius,
  2177. // semiMajorAxis: radius,
  2178. // material: SuperMap3D.Color.DODGERBLUE.withAlpha(0.4),
  2179. // outline: true, //是否显示边框
  2180. // outlineColor: SuperMap3D.Color.BLUE, //边框颜色
  2181. // outlineWidth: 1,
  2182. // heightReference: SuperMap3D.HeightReference.NONE
  2183. // },
  2184. // });
  2185. // that.markerboxEntityRadius.push(markerRadius)
  2186. // }
  2187. }
  2188. // that.createLeftClickDescription()
  2189. that.createRightClickDescription()
  2190. },
  2191. /**
  2192. * 地图画线(贴地)
  2193. */
  2194. setConnectTwoList(connectList, color, withAlpha) {
  2195. let that = this
  2196. //SuperMap3D.Color.fromCssColorString('#67ADDF') 16进制颜色设置
  2197. let material = SuperMap3D.Color.fromCssColorString(color).withAlpha(withAlpha)
  2198. that.connectBoxEntityTwo = that.viewer.entities.add({
  2199. Type: 'Polyline',
  2200. polyline: {
  2201. positions: new SuperMap3D.Cartesian3.fromDegreesArray(connectList),
  2202. clampToGround: true, //贴地 true,不贴地 false
  2203. width: 5,
  2204. material: material
  2205. }
  2206. })
  2207. },
  2208. //移除之前添加的点
  2209. clearM() {
  2210. if (this.markerboxEntity != null && this.markerboxEntity.length > 0) {
  2211. for (let i = 0; i < this.markerboxEntity.length; i++) {
  2212. this.viewer.entities.remove(this.markerboxEntity[i])
  2213. }
  2214. this.markerboxEntity = []
  2215. }
  2216. },
  2217. //移除之前添加的线
  2218. clearC() {
  2219. if (this.connectBoxEntity != null) {
  2220. this.viewer.entities.remove(this.connectBoxEntity)
  2221. this.connectBoxEntity = null
  2222. }
  2223. },
  2224. //移除之前添加的面
  2225. clearG() {
  2226. if (this.graphicsBoxEntity != null) {
  2227. this.viewer.entities.remove(this.graphicsBoxEntity)
  2228. this.graphicsBoxEntity = null
  2229. }
  2230. },
  2231. //移除之前添加的面
  2232. clearGList() {
  2233. for (let i = 0; i < this.graphicsBoxEntityList.length; i++) {
  2234. this.viewer.entities.remove(this.graphicsBoxEntityList[i])
  2235. }
  2236. this.graphicsBoxEntityList = []
  2237. },
  2238. lonAndLatPlacement(lon, lat) {
  2239. let that = this
  2240. if (that.positioningEntity != null) {
  2241. this.viewer.entities.remove(that.positioningEntity)
  2242. }
  2243. that.positioningEntity = that.viewer.entities.add({
  2244. name: "",
  2245. position: new SuperMap3D.Cartesian3.fromDegrees(lon, lat),
  2246. billboard: {
  2247. image: iconList['positioning'],
  2248. width: 48,
  2249. height: 48,
  2250. heightReference: SuperMap3D.HeightReference.CLAMP_TO_GROUND,
  2251. disableDepthTestDistance: Number.POSITIVE_INFINITY
  2252. }
  2253. })
  2254. },
  2255. setIsObtainLaAndLon(isObtainLaAndLon) {
  2256. this.isObtainLaAndLon = isObtainLaAndLon
  2257. },
  2258. clearDW() {
  2259. if (this.positioningEntity != null) {
  2260. this.viewer.entities.remove(this.positioningEntity);
  2261. }
  2262. },
  2263. flyTo(longitude, latitude, height) {
  2264. let that = this
  2265. setTimeout(function() {
  2266. that.viewer.camera.setView({
  2267. destination: new SuperMap3D.Cartesian3.fromDegrees(Number(longitude)-Number(0.115), Number(latitude)-Number(0.27), Number(6000)),
  2268. orientation: {
  2269. heading: SuperMap3D.Math.toRadians(0),
  2270. pitch: SuperMap3D.Math.toRadians(-45),
  2271. roll: 0
  2272. }
  2273. })
  2274. }, 3000)
  2275. },
  2276. openTvwall() {
  2277. this.mapshow = false
  2278. if (this.openZt) {
  2279. this.$emit('fatherMethod', this.dianshiqiang, this.longitude, this.latitude, this.userList)
  2280. } else {
  2281. this.$emit(this._click, this._parameter)
  2282. }
  2283. },
  2284. /**
  2285. * 地图落点
  2286. */
  2287. setMarkers(makerList) {
  2288. let that = this
  2289. for (let i in makerList) {
  2290. let longitude = makerList[i].lng
  2291. let latitude = makerList[i].lat
  2292. let marker = that.viewer.entities.add({
  2293. name: '',
  2294. position: new SuperMap3D.Cartesian3.fromDegrees(Number(longitude), Number(latitude)),
  2295. billboard: {
  2296. image: iconList[makerList[i].icon],
  2297. width: 48,
  2298. height: 48,
  2299. heightReference: SuperMap3D.HeightReference.CLAMP_TO_GROUND,
  2300. disableDepthTestDistance: Number.POSITIVE_INFINITY
  2301. },
  2302. description: makerList[i].bindPopupHtml,
  2303. click: makerList[i].click,
  2304. parameter: makerList[i].parameter
  2305. })
  2306. that.markerboxEntity.push(marker)
  2307. }
  2308. that.viewer.scene.globe.depthTestAgainstTerrain = false
  2309. // that.createLeftClickDescription()
  2310. that.createRightClickDescription()
  2311. },
  2312. /**
  2313. *鼠标左击事件是原来的气泡
  2314. */
  2315. createLeftClickDescription() {
  2316. let that = this
  2317. that.handler.setInputAction(function(movement) {
  2318. that.pick = that.viewer.scene.pick(movement.position)
  2319. if (that.pick && that.pick) {
  2320. let id = SuperMap3D.defaultValue(that.viewer.scene.pick(movement.position).id, that.viewer.scene.pick(
  2321. movement.position).primitive.id)
  2322. let html = id._description
  2323. if (html != undefined && html._value != null && html._value != '') {
  2324. that.bindPopupHtml = html
  2325. that.mapshow = true
  2326. that.openZt = false
  2327. that._click = id._click
  2328. that._parameter = id._parameter
  2329. } else {
  2330. that.mapshow = false
  2331. }
  2332. } else {
  2333. that.mapshow = false
  2334. }
  2335. }, SuperMap3D.ScreenSpaceEventType.LEFT_CLICK)
  2336. },
  2337. /**
  2338. *鼠标右击事件是原来的点击
  2339. */
  2340. createRightClickDescription() {
  2341. let that = this
  2342. that.handler.setInputAction(function(movement) {
  2343. that.mapshow = false
  2344. if (new Date().getTime() - that.clickTime < 2000) {
  2345. return
  2346. } else {
  2347. that.clickTime = new Date().getTime()
  2348. }
  2349. // 监听鼠标的当前位置坐标,然后根据当前坐标去动态更新气泡窗口div的显示位置;
  2350. that.pick = that.viewer.scene.pick(movement.position)
  2351. if (that.pick && that.pick) {
  2352. let id = SuperMap3D.defaultValue(that.viewer.scene.pick(movement.position).id, that.viewer.scene.pick(
  2353. movement.position).primitive.id)
  2354. let clickName = id._click
  2355. that.$emit(clickName, id._parameter)
  2356. }
  2357. }, SuperMap3D.ScreenSpaceEventType.LEFT_CLICK)
  2358. },
  2359. /**
  2360. * 落点定位
  2361. */
  2362. /**
  2363. * 落点定位
  2364. */
  2365. dropLocation(lat, lng, index,radius) {
  2366. this.viewer.scene.globe.depthTestAgainstTerrain = true;
  2367. this.viewer.camera.flyTo({
  2368. destination: new SuperMap3D.Cartesian3.fromDegrees(Number(lng), Number(lat)-Number(0.008), Number(1000)),
  2369. orientation: {
  2370. heading: SuperMap3D.Math.toRadians(0),
  2371. pitch: SuperMap3D.Math.toRadians(-45),
  2372. roll: 0
  2373. }
  2374. })
  2375. if (radius != undefined && radius != null) {
  2376. let that = this
  2377. // 初始化颜色选择控件
  2378. let initialScanColor = '#2263e6'
  2379. that.viewer.scene.scanEffect.color = SuperMap3D.Color.fromCssColorString(initialScanColor)
  2380. // 获取或设置扫描线的运行周期,单位:秒。
  2381. that.viewer.scene.scanEffect.period = radius / 500
  2382. // 获取或设置扫描线的运行速度,单位:米/秒。
  2383. that.viewer.scene.scanEffect.speed = 500
  2384. that.viewer.scene.scanEffect.mode = SuperMap3D.ScanEffectMode.CIRCLE
  2385. that.viewer.scene.scanEffect.centerPostion = new SuperMap3D.Cartesian3.fromDegrees(lng, lat, 3000)
  2386. that.viewer.scene.scanEffect.show = true
  2387. }
  2388. },
  2389. /**
  2390. * 地图画线(贴地)
  2391. */
  2392. setConnectList(connectList, color, withAlpha) {
  2393. let that = this
  2394. //SuperMap3D.Color.fromCssColorString('#67ADDF') 16进制颜色设置
  2395. let material = SuperMap3D.Color.fromCssColorString(color).withAlpha(withAlpha)
  2396. that.connectBoxEntity = that.viewer.entities.add({
  2397. Type: 'Polyline',
  2398. polyline: {
  2399. positions: new SuperMap3D.Cartesian3.fromDegreesArray(connectList),
  2400. clampToGround: true, //贴地 true,不贴地 false
  2401. width: 5,
  2402. material: material
  2403. }
  2404. })
  2405. },
  2406. /**
  2407. * 地图画线(贴地)_批量_图标移动
  2408. */
  2409. setConnectListsMarkerMove(connectList, color, withAlpha) {
  2410. let that = this
  2411. // 确保场景正确初始化
  2412. let material = SuperMap3D.Color.fromCssColorString(color).withAlpha(withAlpha);
  2413. that.connectBoxEntityMove.push(
  2414. that.viewer.entities.add({
  2415. polyline: {
  2416. positions: new SuperMap3D.Cartesian3.fromDegreesArrayHeights(that.getLonLatArray(connectList)),
  2417. // clampToGround: true, //贴地 true,不贴地 false
  2418. width: 10,
  2419. // material: new SuperMap3D.PolylineDynamicMaterialProperty({
  2420. // color: material,
  2421. // outlineWidth: 0.2,
  2422. // outlineColor: SuperMap3D.Color.BLACK
  2423. // })
  2424. material: new SuperMap3D.PolylineTrailMaterialProperty({
  2425. color: material,
  2426. trailLength: 0.8,
  2427. period: 8.0,
  2428. })
  2429. }
  2430. })
  2431. );
  2432. },
  2433. /**
  2434. * 高度添加
  2435. * @param points
  2436. * @returns {*}
  2437. */
  2438. getLonLatArray(connectList) {
  2439. const ret = [];
  2440. for (let i = 0; i<connectList.length;i+=2) {
  2441. ret.push(connectList[i]);
  2442. ret.push(connectList[i+1]);
  2443. ret.push(200);
  2444. }
  2445. return ret;
  2446. },
  2447. /**
  2448. * 地图图形(贴地)
  2449. */
  2450. setGraphicsList(graphicsList, color, withAlpha) {
  2451. let that = this
  2452. //SuperMap3D.Color.fromCssColorString('#67ADDF') 16进制颜色设置
  2453. let material = SuperMap3D.Color.fromCssColorString(color).withAlpha(withAlpha)
  2454. that.graphicsBoxEntity = that.viewer.entities.add({
  2455. polygon: {
  2456. hierarchy: new SuperMap3D.Cartesian3.fromDegreesArray(graphicsList),
  2457. clampToGround: true, //贴地 true,不贴地 false
  2458. width: 5,
  2459. material: material
  2460. }
  2461. })
  2462. },
  2463. // 批量画面
  2464. setGraphicsLists(graphicsList, color, withAlpha) {
  2465. let that = this
  2466. let material = SuperMap3D.Color.fromCssColorString(color).withAlpha(withAlpha)
  2467. for (let i = 0; i < graphicsList.length; i++) {
  2468. let positions = new SuperMap3D.Cartesian3.fromDegreesArray(graphicsList[i].latLng)
  2469. let name = graphicsList[i].name.toString()
  2470. let center = SuperMap3D.BoundingSphere.fromPoints(positions).center
  2471. let namePosition = SuperMap3D.Cartographic.fromCartesian(center)
  2472. namePosition.height = 0 // 将名称高度设置为0,使其贴地显示
  2473. that.graphicsBoxEntityList.push(that.viewer.entities.add({
  2474. polygon: {
  2475. hierarchy: positions,
  2476. clampToGround: true,
  2477. width: 5,
  2478. material: material
  2479. },
  2480. position: center,
  2481. label: {
  2482. text: name,
  2483. font: 'Bold 12px sans-serif',
  2484. fillColor: SuperMap3D.Color.BLACK,
  2485. outlineColor: SuperMap3D.Color.WHITE,
  2486. outlineWidth: 2,
  2487. pixelOffset: new SuperMap3D.Cartesian2(0, 0),
  2488. heightReference: SuperMap3D.HeightReference.CLAMP_TO_GROUND,
  2489. disableDepthTestDistance: Number.POSITIVE_INFINITY
  2490. }
  2491. }))
  2492. }
  2493. }
  2494. }
  2495. }
  2496. </script>
  2497. <style rel="stylesheet/scss" lang="scss" scoped>
  2498. .button {
  2499. text-shadow:none;
  2500. line-height: 25px;
  2501. padding: 0px 10px 0px 10px;
  2502. }
  2503. .map-tit {
  2504. position: absolute;
  2505. top: 90px;
  2506. left: 50%;
  2507. transform: translatex(-50%);
  2508. border: 1px solid #15519b;
  2509. z-index: 9999;
  2510. background: linear-gradient(rgba(4, 23, 62, 0.6), rgba(0, 28, 70, 0.6));
  2511. min-width: 300px;
  2512. .sj-icon-btn {
  2513. display: block;
  2514. margin: 10px auto 15px auto;
  2515. padding: 0px 16px;
  2516. font-size: 10px;
  2517. height: 1.7rem;
  2518. }
  2519. .top-tit {
  2520. width: 100%;
  2521. height: 28px;
  2522. line-height: 28px;
  2523. display: flex;
  2524. flex-direction: row;
  2525. justify-content: space-between;
  2526. background: #15519b80;
  2527. padding: 0px 10px;
  2528. align-items: center;
  2529. i {
  2530. color: #10ccff;
  2531. font-size: 18px;
  2532. text-shadow: 0px 0px 5px #23b3b3;;
  2533. }
  2534. span img {
  2535. display: block;
  2536. width: 12px;
  2537. height: 12px;
  2538. color: #fff;
  2539. cursor: pointer;
  2540. }
  2541. }
  2542. .map-txt {
  2543. padding: 10px 15px;
  2544. color: #fff;
  2545. line-height: 20px;
  2546. font-size: 12px;
  2547. .d-l-con {
  2548. }
  2549. }
  2550. }
  2551. .fade-enter-active,
  2552. .fade-leave-active {
  2553. transition: 1s;
  2554. }
  2555. .fade-enter,
  2556. .fade-leave-to {
  2557. opacity: 0;
  2558. transform: translateY(-10rem);
  2559. }
  2560. .excavation-tool-bar{
  2561. left: 44%;
  2562. top: 40%;
  2563. .form-control{
  2564. background-color: #202F3C;
  2565. border: 1px solid #0FC5F2 !important;
  2566. color: #fff !important;
  2567. text-indent: 5px;
  2568. }
  2569. }
  2570. #excavation{
  2571. border: solid 1px #0f7caf !important;
  2572. background: color(srgb 0.06 0.22 0.37 / 0.7) !important;
  2573. }
  2574. #boxSelection .tool-bar{
  2575. top: 15%;
  2576. border: solid 1px #0f7caf !important;
  2577. background: color(srgb 0.06 0.22 0.37 / 0.7) !important;
  2578. }
  2579. #dig,#clear,#close{
  2580. background-color: #21BCFE;
  2581. border: 1px solid #0FC5F2 !important;
  2582. color: #fff !important;
  2583. cursor: pointer;
  2584. }
  2585. </style>