supermap-2.5d.vue 90 KB

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