supermap-2.5d.vue 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568
  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="dig" class="button black" type="button">开挖</button>
  32. <button id="clear" class="button black" type="button" style="margin-right: 0">清除</button>
  33. </div>
  34. </div>
  35. <!--地图开挖 显示 结束-->
  36. <!--地图开挖分析 显示 结束-->
  37. <div id="excavationAnalyze" v-if="showExcavationAnalyze" class="param-container tool-bar">
  38. <div class="param-item">
  39. <b>开挖高程:</b>
  40. <input type="text" id="depth" value="5000" style="margin-left: 50px;">
  41. </div>
  42. <div class="param-item">
  43. <b>开挖面积(平方米):</b>
  44. <input type="text" id="cutarea" value="" style="margin-left: 10px;">
  45. </div>
  46. <div class="param-item">
  47. <b>开挖体积(立方米):</b>
  48. <input type="text" id="cutVolume" value="" style="margin-left: 10px;">
  49. </div>
  50. <div class="param-item">
  51. <b>填方面积(平方米):</b>
  52. <input type="text" id="fillarea" value="" style="margin-left: 10px;">
  53. </div>
  54. <div class="param-item">
  55. <b>填方体积(立方米):</b>
  56. <input type="text" id="fillVolume" value="" style="margin-left: 10px;">
  57. </div>
  58. <div class="param-item">
  59. <b>未填挖面积(平方米):</b>
  60. <input type="text" id="remainderArea" value="">
  61. </div>
  62. <div class="param-item" style="float: right;">
  63. <button type="button" id="filladd" class="button black">绘制</button>
  64. <button type="button" id="fillclear" class="button black">清除</button>
  65. </div>
  66. </div>
  67. <!--地图开挖分析 显示 结束-->
  68. </div>
  69. </div>
  70. </template>
  71. <script>
  72. import {
  73. iconList,
  74. queryMap,
  75. getDeviceList
  76. } from '@/api/components/supermap.js'
  77. import Cookies from 'js-cookie'
  78. import {
  79. getConfigKey
  80. } from '@/api/system/config'
  81. export default {
  82. name: 'supermap-2.5d',
  83. data() {
  84. return {
  85. showExcavation:false,//开挖图示
  86. showExcavationAnalyze:false,//填开挖分析图示
  87. bindPopupHtml: null,
  88. mapshow: false,
  89. openZt: false,
  90. superMapRootUrl: null,
  91. viewer: null,
  92. scene: null,
  93. handler: null,
  94. pick: null,
  95. markerboxEntity: [], //地图落点实体
  96. connectBoxEntity: null, //地图线实体
  97. graphicsBoxEntity: null, //地图面实体
  98. graphicsBoxEntityList: [], //地图面实体
  99. markerboxEntityRadius: [], //地图落点实体
  100. connectBoxEntityTwo: null, //地图线实体
  101. /*************************原地图属性*********************/
  102. isEditableLayers: false, //绘图控件
  103. selOptV: 2, // 贴地量算
  104. clampMode: 1, // 空间模式
  105. handlerDis: null, // 距离
  106. handlerArea: null, // 面积
  107. handlerHeight: null, // 高度
  108. handlerExcavation: null, // 开挖
  109. handlerExcavationAnalyze: null, // 填开挖分析
  110. isObtainLaAndLon: false,
  111. /*************************原地图属性*********************/
  112. aac: null,
  113. queryParams: {
  114. name: null,
  115. mapData: null,
  116. mapName: null
  117. },
  118. showLayer: true,
  119. clickTime: new Date().getTime(),
  120. /*************************图层过滤属性*********************/
  121. layerList: [],
  122. dianshiqiang: null,
  123. longitude: null,
  124. latitude: null,
  125. userList: null,
  126. dataMap: {},
  127. dataNameMap: {},
  128. lonAndLat: {},
  129. mvtMap: {},
  130. queryList: {},
  131. vdivcesiumContainer: '',
  132. reportSource: '',
  133. eventStatusValue: '',
  134. cameraCode: '',
  135. cameraRadius: '',
  136. imageryProvider_hideList: [], //隐藏图层实体
  137. open_hideList: [], //隐藏图层实体
  138. openModel_hideList: [], //隐藏图层实体
  139. find_hideList: [], //隐藏图层实体
  140. findDisplayed_hideList: [], //隐藏图层实体
  141. /*************************图层过滤属性*********************/
  142. _click: null,
  143. dataMap: {},
  144. _parameter: null,
  145. positioningEntity: null,
  146. }
  147. },
  148. watch: {},
  149. created() {
  150. },
  151. mounted() {
  152. this.showLayer = this.showLayer != undefined ? this.showLayer : false
  153. },
  154. props: {
  155. // showLayer: [Boolean],
  156. },
  157. methods: {
  158. queryMap(deptId) {
  159. queryMap(deptId).then(req => {
  160. req = req.sort(function(a, b) {
  161. return a.sort - b.sort
  162. })
  163. this.onload(req)
  164. }
  165. )
  166. },
  167. onload(supermapUrls) {
  168. let that = this
  169. const withinData = supermapUrls
  170. //1.添加地形数据
  171. that.viewer = new SuperMap3D.Viewer('cesiumContainer', {
  172. //创建地形服务提供者的实例,url为SuperMap iServer发布的TIN地形服务
  173. terrainProvider: new SuperMap3D.SuperMapTerrainProvider({
  174. url: that.superMapRootUrl + '/3D-sipingchangjing/rest/realspace/datas/dem@spyx4326',
  175. //isSct : false,//地形服务源自SuperMap iServer发布时需设置isSct为true
  176. invisibility: true
  177. }),
  178. infoBox: false,
  179. navigation: false
  180. }, {
  181. contextOptions: {
  182. msaaLevel: 4,
  183. requestWebgl2: true
  184. },
  185. orderIndependentTranslucency: false
  186. })
  187. that.scene = that.viewer.scene
  188. that.viewer._Widget._creditContainer.style.display = "none" // 去掉超图logo水印
  189. //2.添加SuperMap iServer发布的影像服务
  190. that.addImageryProvider(withinData[0].path)
  191. let longitude = withinData[0].coordinate.split(',')[0]
  192. let latitude = withinData[0].coordinate.split(',')[1]
  193. let height = withinData[0].scale
  194. setTimeout(function() {
  195. for (let i = 1; i < withinData.length; i++) {
  196. setTimeout(() => {
  197. if (withinData[i].type == 'addImagery') {
  198. if(withinData[i].note == '图层过滤'){
  199. return
  200. }
  201. that.addImageryProvider(withinData[i].path)
  202. } else if (withinData[i].type == 'addVectorTilesMap') {
  203. that.addVectorTilesMap(withinData[i].path)
  204. } else if (withinData[i].type == 'open') {
  205. if(withinData[i].note == '图层过滤'){
  206. return
  207. }
  208. that.addOpen(withinData[i].sort, withinData[i].path)
  209. }else if (withinData[i].type == 'open_model') {
  210. if(withinData[i].note == '图层过滤'){
  211. return
  212. }
  213. that.addOpen_model(withinData[i].sort, withinData[i].path)
  214. } else if (withinData[i].type == 'find') {
  215. that.addFind(withinData[i].parentId, withinData[i].path)
  216. }else if (withinData[i].type == 'findDisplayed') {
  217. that.addFind(withinData[i].parentId, withinData[i].path)
  218. }
  219. }, 100 * i)
  220. }
  221. // that.scene.open('http://116.142.80.12:8090/iserver/services/3D-SiPingReLi/rest/realspace')
  222. // that.scene.open('http://116.142.80.12:8090/iserver/services/3D-huashengranqi/rest/realspace')
  223. }, 2000)
  224. that.viewer.selectedEntityChanged.addEventListener(function(entity) {
  225. if (entity != undefined && Reflect.has(entity, 'layerID')) {
  226. that.queryParams.name = entity.pickResult[entity.layerID][0].feature.properties.Name
  227. that.queryParams.mapData = entity.pickResult[entity.layerID][0].feature.properties.SmUserID
  228. that.queryParams.mapName = entity.pickResult[entity.layerID][0].feature.properties.layer
  229. getDeviceList(that.queryParams).then(res => {
  230. that.openZt = true
  231. const treeLabels = [{
  232. 'id': null,
  233. 'labelCode': '999',
  234. 'labelName': '电视墙',
  235. 'cameraType': null,
  236. 'parentLabelCode': ''
  237. }]
  238. const labelChannels = []
  239. for (let i in res.data) {
  240. if (res.data[i].cameraCode != null) {
  241. treeLabels.push({
  242. 'id': null,
  243. 'labelCode': res.data[i].cameraCode,
  244. 'labelName': res.data[i].cameraName,
  245. 'cameraType': '1',
  246. 'parentLabelCode': '999'
  247. })
  248. labelChannels.push({
  249. 'labelCode': res.data[i].cameraCode,
  250. 'channelDates': [{
  251. 'channelCode': res.data[i].cameraCode,
  252. 'channelName': res.data[i].cameraName,
  253. 'channelSn': null,
  254. 'cameraType': '1',
  255. 'online': '1',
  256. 'cameraCode': '1'
  257. }]
  258. })
  259. }
  260. }
  261. that.dianshiqiang = [{
  262. 'switchTab': '2',
  263. 'treeLabels': treeLabels,
  264. 'labelChannels': labelChannels
  265. }]
  266. that.longitude = res.data[0].longitude
  267. that.latitude = res.data[0].latitude
  268. that.userList = res.data[0].userList
  269. let html =
  270. '<div class="map-tip">' +
  271. '<span>' +
  272. ' <div class="d-l-con">' +
  273. ' <div class="d-l-l-text">' +
  274. ' <h4>名称:' + res.data[0].name +
  275. '</h4>' +
  276. ' </div>' +
  277. ' </div>' +
  278. ' </span>'
  279. for (let i in res.data[0].userList) {
  280. html += '<span>' +
  281. ' <div class="d-l-con">' +
  282. ' <div class="d-l-l-text">' +
  283. ' <h4>' + res.data[0].userList[i].position + ':' + res.data[0].userList[i]
  284. .name + '</h4>' +
  285. ' </div>' +
  286. ' </div>' +
  287. ' </span>' +
  288. '<span>' +
  289. ' <div class="d-l-con">' +
  290. ' <div class="d-l-l-text">' +
  291. ' <h4>电话:' + (res.data[0].userList[i].phone ? res.data[0].userList[i].phone :
  292. '') + '</h4>' +
  293. ' </div>' +
  294. ' </div>' +
  295. ' </span>'
  296. }
  297. html += '</div>'
  298. that.bindPopupHtml = html
  299. that.openTvwall()
  300. })
  301. }
  302. });
  303. that.handler = new SuperMap3D.ScreenSpaceEventHandler(that.scene.canvas);
  304. that.flyTo(longitude, latitude, height)
  305. //设置鼠标左键单击回调事件
  306. that.handler.setInputAction(function (e) {
  307. if (that.isObtainLaAndLon) {
  308. if (that.positioningEntity != null) {
  309. that.viewer.entities.remove(that.positioningEntity);
  310. }
  311. //首先移除之前添加的点
  312. // viewer.entities.removeAll();
  313. //获取点击位置笛卡尔坐标
  314. var position = that.scene.pickPosition(e.position);
  315. //将笛卡尔坐标转化为经纬度坐标
  316. var cartographic = SuperMap3D.Cartographic.fromCartesian(position);
  317. var longitude = SuperMap3D.Math.toDegrees(cartographic.longitude);
  318. var latitude = SuperMap3D.Math.toDegrees(cartographic.latitude);
  319. var height = cartographic.height;
  320. if (height < 0) {
  321. height = 0;
  322. }
  323. that.positioningEntity = that.viewer.entities.add({
  324. name: "",
  325. position: new SuperMap3D.Cartesian3.fromDegrees(longitude, latitude),
  326. billboard: {
  327. image: iconList['positioning'],
  328. width: 48,
  329. height: 48,
  330. heightReference: SuperMap3D.HeightReference.CLAMP_TO_GROUND,
  331. disableDepthTestDistance: Number.POSITIVE_INFINITY
  332. },
  333. })
  334. that.$emit('setPositioning', longitude, latitude);
  335. }
  336. }, SuperMap3D.ScreenSpaceEventType.LEFT_CLICK);
  337. },
  338. //初始化地图数据
  339. removeAllviewer(deptId, index) {
  340. if (index != -1) {
  341. $('#cesiumContainer').remove()
  342. $('#supermap3D').append(
  343. '<div id="cesiumContainer" style="width: 100%; height: 100%;background: none;" >\n' +
  344. ' </div>')
  345. }
  346. let that = this
  347. that.superMapInfo(deptId)
  348. },
  349. superMapInfo(index) {
  350. let deptId = index;
  351. getConfigKey('superMap.iServer').then(response => {
  352. this.superMapRootUrl = response.msg
  353. // this.queryMap(index)
  354. Cookies.set('superMap.iServer', response.msg)
  355. setTimeout(() =>
  356. this.queryVectorTilesMapList(deptId) //切换地图
  357. ,1000
  358. )
  359. })
  360. },
  361. // ***************************图层过滤 开始************************************************
  362. reload(list) {
  363. this.removeAllMvt()
  364. this.removeAllImageryProvider_hide()
  365. this.removeAllOpen_hide()
  366. this.removeAllOpenModel_hide()
  367. this.layerList = list
  368. let that = this
  369. for (let i = 0; i < this.layerList.length; i++) {
  370. let data = this.queryList.filter(item => item.id == this.layerList[i]) [0]
  371. if (data.type == 'addImagery') {
  372. let imageryProvider = that.addImageryProvider(data.path)
  373. that.imageryProvider_hideList.push(imageryProvider)
  374. } else if(data.type=='addVectorTilesMap'){
  375. for (let key in that.mvtMap) {
  376. if (data.id == key) {
  377. that.mvtMap[key].show = true
  378. let dat = this.queryList.filter(item => item.parentId == data.id)
  379. for (let j = 0; j < dat.length; j++) {
  380. let da = this.queryList.filter(item => item.parentId == dat[j].id)
  381. for (let k = 0; k < da.length; k++) {
  382. for (let dataNameMapKey in that.dataNameMap) {
  383. if (dataNameMapKey == da[k].id) {
  384. this.dataMap[da[k].parentId].then(function() {
  385. that.dataNameMap[dataNameMapKey].visible = true
  386. })
  387. }
  388. }
  389. }
  390. }
  391. }
  392. }
  393. } else if (data.type == 'open') {
  394. let open = that.addOpen(data.id, data.path)
  395. that.open_hideList.push(open)
  396. } else if (data.type == 'open_model') {
  397. let openModel = that.addOpen_model(data.id, data.path)
  398. that.openModel_hideList.push(openModel)
  399. } else if (data.type == 'find') {
  400. let find = that.addFind(data.id, data.path)
  401. that.find_hideList.push(find)
  402. } else if (data.type == 'findDisplayed') {
  403. let findDisplayed = that.addFindDisplayed(data.id, data.path)
  404. that.findDisplayed_hideList.push(findDisplayed)
  405. }
  406. }
  407. },
  408. removeAllMvt() {
  409. let that = this
  410. // 移除方法,暂存:this.viewer.scene.removeVectorTilesMap(this.mvtMap.name);
  411. for (let i = 0; i < this.queryList.length; i++) {
  412. let data = this.queryList[i]
  413. for (let key in that.mvtMap) {
  414. if (data.id == key) {
  415. that.mvtMap[key].show = false
  416. let dat = this.queryList.filter(item => item.parentId == data.id)
  417. for (let j = 0; j < dat.length; j++) {
  418. if (dat[j].parentId != null) {
  419. let da = this.queryList.filter(item => item.parentId == dat[j].id)
  420. for (let k = 0; k < da.length; k++) {
  421. for (let dataNameMapKey in that.dataNameMap) {
  422. this.dataMap[da[k].parentId].then(function() {
  423. that.dataNameMap[dataNameMapKey].visible = false
  424. })
  425. }
  426. }
  427. }
  428. }
  429. }
  430. }
  431. }
  432. },
  433. removeAllImageryProvider_hide() {
  434. let that = this
  435. if (that.imageryProvider_hideList != null && that.imageryProvider_hideList.length > 0) {
  436. for (let i = 0; i < that.imageryProvider_hideList.length; i++) {
  437. that.viewer.imageryLayers.remove(that.imageryProvider_hideList[i])
  438. }
  439. that.imageryProvider_hideList = []
  440. }
  441. },
  442. removeAllOpen_hide() {
  443. let that = this
  444. if (that.open_hideList != null && that.open_hideList.length > 0) {
  445. for (let i = 0; i < that.open_hideList.length; i++) {
  446. SuperMap3D.when.all(that.open_hideList[i], function (layers) {
  447. for (var layer of layers) {
  448. that.scene.layers.remove(layer.name);
  449. }
  450. });
  451. }
  452. that.open_hideList = []
  453. }
  454. },
  455. removeAllOpenModel_hide() {
  456. let that = this
  457. if (that.openModel_hideList != null && that.openModel_hideList.length > 0) {
  458. for (let i = 0; i < that.openModel_hideList.length; i++) {
  459. SuperMap3D.when.all(that.openModel_hideList[i], function (layers) {
  460. const reversedLayers = [...layers].reverse();
  461. for (var layer of reversedLayers) {
  462. that.scene.layers.remove(layer.name);
  463. that.viewer.imageryLayers.remove(layer)
  464. }
  465. });
  466. }
  467. that.openModel_hideList = []
  468. }
  469. },
  470. addFindDisplayed(id, uri) {
  471. let that = this
  472. let data = that.queryList.filter(item => item.id == id)[0]
  473. that.dataMap[data.parentId].then(function(layers) {
  474. let obj = that.scene.layers.find(uri) //区县文字图层
  475. //加载后隐藏
  476. obj.visible = false
  477. // //关闭避让
  478. obj.isOverlapDisplayed = true
  479. that.dataNameMap[id] = obj
  480. return obj
  481. })
  482. },
  483. addFind(id, uri){
  484. let that = this;
  485. let data = that.queryList.filter(item => item.id === id)
  486. if(data.length === 0) {
  487. return;
  488. }
  489. that.dataMap[data[0].parentId].then(function(layers) {
  490. let obj = that.scene.layers.find(uri) //区县文字图层
  491. return obj
  492. })
  493. },
  494. addOpen_model(sort, uri) {
  495. let that = this
  496. // that.dataMap[sort] = that.scene.open(that.superMapRootUrl + uri)
  497. let obj = that.dataMap[sort] = that.scene.open(that.superMapRootUrl + uri)
  498. //开始加载专题图等数据,8秒后开始执行
  499. setTimeout(function () {
  500. /**
  501. * @param dom ScreenSpaceEventHandler操作的dom节点,画的框会成为其子节点
  502. */
  503. function DrawRectHandler(dom) {
  504. let startPoint,
  505. self = this,
  506. isShiftAndLeftDown = false,
  507. handler = new SuperMap3D.ScreenSpaceEventHandler(dom),
  508. removalFunctions = [],
  509. rect = new Rect(dom)
  510. this.isDestroyed = false
  511. this.activeEvt = new SuperMap3D.Event()
  512. this.cancelEvt = new SuperMap3D.Event()
  513. this.movingEvt = new SuperMap3D.Event()
  514. this.drawEvt = new SuperMap3D.Event()
  515. // div框
  516. function Rect(parentDom) {
  517. this.rect = document.createElement('div')
  518. this.rect.style.visibility = 'hidden'
  519. parentDom.appendChild(this.rect)
  520. this.leftTopPoint = new SuperMap3D.Cartesian2()
  521. this.rightBottomPoint = new SuperMap3D.Cartesian2()
  522. Rect.prototype.setPosition = function (startPoint, endPosition) {
  523. let w = endPosition.x - startPoint.x
  524. let h = endPosition.y - startPoint.y
  525. let left, top, width, height
  526. if (w < 0) {
  527. left = endPosition.x
  528. width = -w
  529. } else {
  530. left = startPoint.x
  531. width = w
  532. }
  533. if (h < 0) {
  534. top = endPosition.y
  535. height = -h
  536. } else {
  537. top = startPoint.y
  538. height = h
  539. }
  540. this.leftTopPoint = new SuperMap3D.Cartesian2(left, top)
  541. this.rightBottomPoint = new SuperMap3D.Cartesian2(left + width, top + height)
  542. this.rect.style = `position:fixed;top:${top}px;left:${left}px;width:${width}px;height:${height}px;border:2px dashed #333;`
  543. this.setVisible(true)
  544. }
  545. Rect.prototype.setVisible = function (isVisible) {
  546. this.rect.style.visibility = isVisible ? 'visible' : 'hidden'
  547. }
  548. Rect.prototype.getRectPoint = function () {
  549. return {
  550. leftTopPoint: this.leftTopPoint,
  551. rightBottomPoint: this.rightBottomPoint
  552. }
  553. }
  554. Rect.prototype.destroy = function () {
  555. dom.removeChild(rect)
  556. this.rect = null
  557. }
  558. }
  559. // canvas框
  560. function RectCanvas(parentDom) {
  561. let canvas = document.createElement('canvas'),
  562. ctx = canvas.getContext('2d')
  563. this.canvas = canvas
  564. canvas.width = parentDom.clientWidth
  565. canvas.height = parentDom.clientHeight
  566. canvas.style = 'position:fixed;top:0;left:0;z-index:-1'
  567. parentDom.appendChild(canvas)
  568. this.leftTopPoint = new SuperMap3D.Cartesian2()
  569. this.rightBottomPoint = new SuperMap3D.Cartesian2()
  570. RectCanvas.prototype.setPosition = function (startPoint, endPosition) {
  571. let w = endPosition.x - startPoint.x
  572. let h = endPosition.y - startPoint.y
  573. let left, top, width, height
  574. if (w < 0) {
  575. left = endPosition.x
  576. width = -w
  577. } else {
  578. left = startPoint.x
  579. width = w
  580. }
  581. if (h < 0) {
  582. top = endPosition.y
  583. height = -h
  584. } else {
  585. top = startPoint.y
  586. height = h
  587. }
  588. this.leftTopPoint = new SuperMap3D.Cartesian2(left, top)
  589. this.rightBottomPoint = new SuperMap3D.Cartesian2(left + width, top + height)
  590. ctx.clearRect(0, 0, canvas.width, canvas.height)
  591. ctx.strokeRect(left, top, width, height)
  592. }
  593. RectCanvas.prototype.setVisible = function (isVisible) {
  594. if (isVisible) {
  595. canvas.style.zIndex = '999'
  596. } else {
  597. canvas.style.zIndex = '-1'
  598. }
  599. }
  600. RectCanvas.prototype.getRectPoint = function () {
  601. return {
  602. leftTopPoint: this.leftTopPoint,
  603. rightBottomPoint: this.rightBottomPoint
  604. }
  605. }
  606. RectCanvas.prototype.destroy = function () {
  607. dom.removeChild(canvas)
  608. ctx = null
  609. this.canvas = null
  610. }
  611. }
  612. // 开关相机控制
  613. function setCameraCtrl(isActive) {
  614. let cameraCtrl = that.scene.screenSpaceCameraController
  615. cameraCtrl.enableRotate = isActive
  616. cameraCtrl.enableTranslate = isActive
  617. cameraCtrl.enableZoom = isActive
  618. cameraCtrl.enableTilt = isActive
  619. cameraCtrl.enableLook = isActive
  620. }
  621. // 鼠标cursor控制
  622. function toggleCursorStyle(isActive) {
  623. if (isActive) {
  624. that.viewer.enableCursorStyle = false
  625. that.viewer._element.style.cursor = ''
  626. dom.style.cursor = 'default'
  627. } else {
  628. that.viewer.enableCursorStyle = true
  629. }
  630. }
  631. // 初始化事件处理
  632. function initEvent() {
  633. handler.setInputAction(function (e) {
  634. isShiftAndLeftDown = true
  635. startPoint = new SuperMap3D.Cartesian2(e.position.x, e.position.y)
  636. }, SuperMap3D.ScreenSpaceEventType.LEFT_DOWN, SuperMap3D.KeyboardEventModifier.SHIFT)
  637. // shift松开时,始终将rect隐藏
  638. let keyUpFunction = function (e) {
  639. self.cancelEvt.raiseEvent()
  640. if (e.key == 'Shift' && isShiftAndLeftDown && !self.isDestroyed) {
  641. isShiftAndLeftDown = false
  642. rect.setVisible(false)
  643. }
  644. }
  645. document.addEventListener('keyup', keyUpFunction)
  646. removalFunctions.push(function () {
  647. document.removeEventListener('keyup', keyUpFunction)
  648. })
  649. handler.setInputAction(function (e) {
  650. let endPosition = e.endPosition
  651. self.activeEvt.raiseEvent(endPosition)
  652. if (!isShiftAndLeftDown) return
  653. rect.setPosition(startPoint, endPosition)
  654. rect.setVisible(true)
  655. self.movingEvt.raiseEvent(rect.getRectPoint())
  656. }, SuperMap3D.ScreenSpaceEventType.MOUSE_MOVE, SuperMap3D.KeyboardEventModifier.SHIFT)
  657. handler.setInputAction(function (e) {
  658. isShiftAndLeftDown = false
  659. rect.setVisible(false)
  660. self.drawEvt.raiseEvent(rect.getRectPoint())
  661. }, SuperMap3D.ScreenSpaceEventType.LEFT_UP, SuperMap3D.KeyboardEventModifier.SHIFT)
  662. handler.setInputAction(function (e) {
  663. isShiftAndLeftDown = false
  664. rect.setVisible(false)
  665. }, SuperMap3D.ScreenSpaceEventType.LEFT_UP)
  666. }
  667. // 移除事件监听
  668. function removeEvent() {
  669. handler.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_DOWN, SuperMap3D.KeyboardEventModifier.SHIFT)
  670. handler.removeInputAction(SuperMap3D.ScreenSpaceEventType.MOUSE_MOVE, SuperMap3D.KeyboardEventModifier.SHIFT)
  671. handler.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_UP, SuperMap3D.KeyboardEventModifier.SHIFT)
  672. handler.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_UP)
  673. }
  674. DrawRectHandler.prototype.destroy = function () {
  675. if (this.isDestroyed) return
  676. setCameraCtrl(true)
  677. removeEvent()
  678. for (let i = 0, j = removalFunctions.length; i < j; i++) {
  679. removalFunctions[i]()
  680. }
  681. handler.destroy()
  682. rect.destroy()
  683. rect = null
  684. this.isDestroyed = true
  685. }
  686. DrawRectHandler.prototype.activate = function () {
  687. if (this.isDestroyed) return
  688. setCameraCtrl(false)
  689. toggleCursorStyle(true)
  690. initEvent()
  691. }
  692. DrawRectHandler.prototype.deactivate = function () {
  693. if (this.isDestroyed) return
  694. setCameraCtrl(true)
  695. toggleCursorStyle(false)
  696. removeEvent()
  697. }
  698. }
  699. new SuperMap3D.when(that.dataMap[sort], function (layers) {
  700. for (let layer of layers) {
  701. layer.selectColorType = 1
  702. that.selectedObjs[layer.name] = []
  703. that.resetIds[layer.name] = []
  704. }
  705. let drawRect = that.drawRect = new DrawRectHandler(document.body)
  706. // res为框的左上点与右下点的相对于给定dom节点的坐标
  707. drawRect.drawEvt.addEventListener(function (res) {
  708. for (let layer of layers) {
  709. layer.selectColorType = 1
  710. }
  711. that.tooltip = false
  712. let selectedColor = new SuperMap3D.Color(1, 0, 0, 1)
  713. that.scene.pickRect(res.leftTopPoint, res.rightBottomPoint)
  714. let objs = that.scene.getPickRectIDs()
  715. let selectedObjs = that.selectedObjs
  716. let resetIds = that.resetIds
  717. for (let k in selectedObjs) {
  718. if (selectedObjs[k].length > 0) {
  719. that.scene.layers.find(k).removeObjsColor(selectedObjs[k])
  720. }
  721. }
  722. if (that.kuangxuan) {
  723. for (let layer of layers) {
  724. let layerName = layer.name
  725. if (layerName === undefined) break
  726. let layerSlt = objs.find(e => e.layerName === layerName)
  727. let sltIds = (layerSlt && layerSlt.ids) || []
  728. resetIds[layerName] = selectedObjs[layerName]
  729. selectedObjs[layerName] = sltIds
  730. that.$parent.$refs.ldTk.FrameSelectedData(sltIds)
  731. that.$parent.$refs.ldTk.allLouDongDialog = true
  732. layer.setObjsColor(selectedObjs[layerName], selectedColor)
  733. }
  734. }
  735. })
  736. drawRect.movingEvt.addEventListener(function (res) {
  737. that.tooltip = true
  738. if (that.kuangxuan) {
  739. that.tooltipText = "松开鼠标左键以结束选择区域"
  740. for (let layer of layers) {
  741. layer.selectColorType = 1
  742. }
  743. that.scene.pickRect(res.leftTopPoint, res.rightBottomPoint)
  744. } else {
  745. that.tooltipText = "请点击框选"
  746. }
  747. })
  748. drawRect.activeEvt.addEventListener(function (position) {
  749. that.tooltip = true
  750. if (that.kuangxuan) {
  751. that.tooltipText = "松开鼠标左键以结束选择区域"
  752. } else {
  753. that.tooltipText = "请点击框选"
  754. }
  755. })
  756. drawRect.cancelEvt.addEventListener(function () {
  757. that.tooltip = false
  758. })
  759. let canvas = document.querySelector('div.cesium-widget canvas')
  760. canvas.setAttribute('tabindex', '0') // needed to put focus on the canvas
  761. canvas.focus()
  762. document.addEventListener('keydown', function (e) {
  763. if (e.key === 'Shift') {
  764. drawRect.activate()
  765. }
  766. })
  767. document.addEventListener('keyup', function (e) {
  768. if (e.key === 'Shift') {
  769. drawRect.deactivate()
  770. }
  771. })
  772. }, function () {
  773. // let title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?'
  774. // widget.showErrorPanel(title, undefined, e)
  775. }).then(function () {
  776. }, function (e) {
  777. console.log(e)
  778. })
  779. }, 3000);
  780. return obj
  781. },
  782. addOpen(id, uri) {
  783. let that = this;
  784. let obj = that.scene.open(that.superMapRootUrl + uri)
  785. that.dataMap[id] = obj
  786. return obj;
  787. },
  788. addVectorTilesMap(uri) {
  789. let that = this
  790. that.scene.addVectorTilesMap({
  791. url: that.superMapRootUrl + uri,
  792. canvasWidth: 512,
  793. name: 'mvt_map3',
  794. viewer: that.viewer,
  795. show: true
  796. })
  797. },
  798. addImageryProvider(uri){
  799. let that = this;
  800. let obj = that.viewer.imageryLayers.addImageryProvider(new SuperMap3D.SuperMapImageryProvider({
  801. url:that.superMapRootUrl + uri
  802. }));
  803. return obj;
  804. },
  805. // ************************************************************************图层过滤 结束***********************************************************************************
  806. // 清除测距、测面、测高
  807. closeMeasuringAll() {
  808. if (this.handlerDis != null) {
  809. this.handlerDis.clear()
  810. }
  811. if (this.handlerArea != null) {
  812. this.handlerArea.clear()
  813. }
  814. if (this.handlerHeight != null) {
  815. this.handlerHeight.clear()
  816. }
  817. },
  818. // 清除开挖,填开挖分析
  819. closeExcavationAll() {
  820. if (this.handlerExcavation != null) {
  821. this.handlerExcavation.deactivate();
  822. this.handlerExcavation.clear();
  823. this.viewer.scene.globe.removeAllExtractRegion();
  824. this.showExcavation = false//开挖图示
  825. }
  826. if (this.handlerExcavationAnalyze != null) {
  827. this.viewer.scene.globe.removeAllModifyRegion();
  828. document.getElementById("cutarea").value = "";
  829. document.getElementById("cutVolume").value = "";
  830. document.getElementById("fillarea").value = "";
  831. document.getElementById("fillVolume").value = "";
  832. document.getElementById("remainderArea").value = "";
  833. this.handlerExcavationAnalyze.clear();
  834. this.showExcavationAnalyze = false//开挖分析图示
  835. }
  836. },
  837. // 测量距离
  838. choseMeasuringDistance() {
  839. let that = this
  840. if (that.handlerDis != null) {
  841. that.handlerDis.deactivate()
  842. that.handlerDis.clear()
  843. }
  844. //初始化测量距离
  845. that.handlerDis = new SuperMap3D.MeasureHandler(that.viewer, SuperMap3D.MeasureMode.Distance, that.clampMode)
  846. that.handlerDis.clampMode = 1
  847. //注册测距功能事件
  848. that.handlerDis.measureEvt.addEventListener(function(result) {
  849. var dis = Number(result.distance)
  850. var selOptV = that.selOptV
  851. if (selOptV == 3 || selOptV == 4) {
  852. dis = Number(calcClampDistance(positions))
  853. }
  854. var distance = dis > 1000 ? (dis / 1000).toFixed(2) + 'km' : dis.toFixed(2) + 'm'
  855. that.handlerDis.disLabel.text = '距离:' + distance
  856. })
  857. that.handlerDis.activeEvt.addEventListener(function(isActive) {
  858. if (isActive == true) {
  859. that.viewer.enableCursorStyle = false
  860. that.viewer._element.style.cursor = ''
  861. $('#super2').removeClass('measureCur').addClass('measureCur')
  862. that.viewer.scene.pickPointEnabled = false
  863. } else {
  864. that.viewer.enableCursorStyle = true
  865. $('#super2').removeClass('measureCur')
  866. that.viewer.scene.pickPointEnabled = false
  867. }
  868. })
  869. that.handlerDis.activate()
  870. },
  871. // 测量面积
  872. choseMeasuringArea() {
  873. let that = this
  874. if (that.handlerArea != null) {
  875. // that.handlerArea.deactivate()
  876. that.handlerArea.clear()
  877. }
  878. //初始化测量面积
  879. that.handlerArea = new SuperMap3D.MeasureHandler(that.viewer, SuperMap3D.MeasureMode.Area, that.clampMode)
  880. that.handlerArea.clampMode = 1
  881. that.handlerArea.measureEvt.addEventListener(function(result) {
  882. var mj = Number(result.area)
  883. var area = mj > 1000000 ? (mj / 1000000).toFixed(2) + 'km²' : mj.toFixed(2) + '㎡'
  884. that.handlerArea.areaLabel.text = '面积:' + area
  885. })
  886. that.handlerArea.activeEvt.addEventListener(function(isActive) {
  887. if (isActive == true) {
  888. that.viewer.enableCursorStyle = false
  889. that.viewer._element.style.cursor = ''
  890. $('#super2').removeClass('measureCur').addClass('measureCur')
  891. that.viewer.scene.pickPointEnabled = false
  892. } else {
  893. that.viewer.enableCursorStyle = true
  894. that.viewer._element.style.cursor = ''
  895. $('#super2').removeClass('measureCur')
  896. that.viewer.scene.pickPointEnabled = false
  897. }
  898. })
  899. that.handlerArea.activate()
  900. },
  901. // 测量高度
  902. choseMeasuringHeight() {
  903. let that = this
  904. if (that.handlerHeight != null) {
  905. // that.handlerHeight.deactivate()
  906. that.handlerHeight.clear()
  907. }
  908. //初始化测量高度
  909. that.handlerHeight = new SuperMap3D.MeasureHandler(that.viewer, SuperMap3D.MeasureMode.DVH);
  910. that.handlerHeight.measureEvt.addEventListener(function (result) {
  911. var distance = result.distance > 1000 ? (result.distance / 1000).toFixed(2) + 'km' : result.distance + 'm';
  912. var vHeight = result.verticalHeight > 1000 ? (result.verticalHeight / 1000).toFixed(2) + 'km' : result.verticalHeight + 'm';
  913. var hDistance = result.horizontalDistance > 1000 ? (result.horizontalDistance / 1000).toFixed(2) + 'km' : result.horizontalDistance + 'm';
  914. that.handlerHeight.disLabel.text = '空间距离:' + distance;
  915. that.handlerHeight.vLabel.text = '垂直高度:' + vHeight;
  916. that.handlerHeight.hLabel.text = '水平距离:' + hDistance;
  917. //实时等高线显示
  918. lineHeight = Number(result.endHeight);
  919. if (isShowLine) updateContourLine(lineHeight)
  920. });
  921. that.handlerHeight.activeEvt.addEventListener(function (isActive) {
  922. if (isActive == true) {
  923. that.viewer.enableCursorStyle = false;
  924. that.viewer._element.style.cursor = '';
  925. $('body').removeClass('measureCur').addClass('measureCur');
  926. that.viewer.scene.pickPointEnabled = pickPointEnabled;
  927. }
  928. else {
  929. that.viewer.enableCursorStyle = true;
  930. $('body').removeClass('measureCur');
  931. that.viewer.scene.pickPointEnabled = false;
  932. }
  933. });
  934. that.handlerHeight.activate()
  935. },
  936. //开挖
  937. excavation(){
  938. let that = this
  939. that.showExcavation=true
  940. setTimeout(function() {
  941. var tooltip = createTooltip(document.body);
  942. that.handlerExcavation = new SuperMap3D.DrawHandler(that.viewer, SuperMap3D.DrawMode.Polygon);
  943. that.handlerExcavation.activeEvt.addEventListener(function(isActive) {
  944. if(isActive == true) {
  945. that.viewer.enableCursorStyle = false;
  946. that.viewer._element.style.cursor = '';
  947. $('body').removeClass('drawCur').addClass('drawCur');
  948. } else {
  949. that.viewer.enableCursorStyle = true;
  950. $('body').removeClass('drawCur');
  951. }
  952. });
  953. that.handlerExcavation.movingEvt.addEventListener(function(windowPosition) {
  954. if(that.handlerExcavation.isDrawing) {
  955. tooltip.showAt(windowPosition, '<p>绘制多边形,</p><p>右键结束绘制.</p>');
  956. } else {
  957. tooltip.showAt(windowPosition, '<p>点击绘制第一个点</p>');
  958. }
  959. });
  960. that.handlerExcavation.drawEvt.addEventListener(function(res) {
  961. var positions = [].concat(res.object.positions);
  962. var positionsDegrees = [];
  963. for(var i = 0; i < positions.length; i++) {
  964. var cartographic = SuperMap3D.Cartographic.fromCartesian(positions[i]);
  965. var lon = SuperMap3D.Math.toDegrees(cartographic.longitude);
  966. var lat = SuperMap3D.Math.toDegrees(cartographic.latitude);
  967. var h = cartographic.height;
  968. positionsDegrees = positionsDegrees.concat([lon, lat, h]);
  969. }
  970. extract(positionsDegrees);
  971. that.handlerExcavation.clear();
  972. that.handlerExcavation.deactivate();
  973. tooltip.setVisible(false);
  974. })
  975. //地形抽出部分
  976. function extract(positions) {
  977. that.viewer.scene.globe.removeAllExtractRegion();
  978. that.viewer.scene.globe.addExtractRegion({
  979. name: 'extract', //名称
  980. position: positions, //区域
  981. height: $('#depth').val(), //开挖深度
  982. transparent: false, //封边是否透明
  983. extractHeight: Number($('#moveHeight').val()), //抽出高度
  984. granularity: 1 //精度
  985. });
  986. }
  987. //清除剖切结果
  988. $('#clear').click(function() {
  989. tooltip.setVisible(false);
  990. that.handlerExcavation.deactivate();
  991. that.handlerExcavation.clear();
  992. that.viewer.scene.globe.removeAllExtractRegion();
  993. });
  994. $("#dig").click(function() {
  995. that.handlerExcavation.activate();
  996. });
  997. $('#loadingbar').remove();
  998. }, 1000)
  999. },
  1000. //填开挖分析
  1001. excavationAnalyze(){
  1002. let that = this
  1003. that.showExcavationAnalyze=true
  1004. setTimeout(function() {
  1005. var tooltip = createTooltip(document.body);
  1006. that.handlerExcavationAnalyze = new SuperMap3D.DrawHandler(that.viewer, SuperMap3D.DrawMode.Polygon, that.clampMode);
  1007. that.handlerExcavationAnalyze.activeEvt.addEventListener(function (isActive) {
  1008. if (isActive == true) {
  1009. that.viewer.enableCursorStyle = false;
  1010. that.viewer._element.style.cursor = '';
  1011. $('body').removeClass('drawCur').addClass('drawCur');
  1012. } else {
  1013. that.viewer.enableCursorStyle = true;
  1014. $('body').removeClass('drawCur');
  1015. }
  1016. });
  1017. that.handlerExcavationAnalyze.movingEvt.addEventListener(function (windowPosition) {
  1018. if (that.handlerExcavationAnalyze.isDrawing) {
  1019. tooltip.showAt(windowPosition, '<p>点击确定多边形中间点</p><p>右键单击结束绘制</p>');
  1020. } else {
  1021. tooltip.showAt(windowPosition, '<p>点击绘制第一个点</p>');
  1022. }
  1023. });
  1024. that.handlerExcavationAnalyze.drawEvt.addEventListener(function (result) {
  1025. that.handlerExcavationAnalyze.polygon.show = false;
  1026. // that.handlerExcavationAnalyze.polyline.show = false;
  1027. that.handlerExcavationAnalyze.deactivate();
  1028. tooltip.setVisible(false);
  1029. var dep = document.getElementById("depth").value;
  1030. var array = [].concat(result.object.positions);
  1031. var positions = [];
  1032. var positionsii = [];
  1033. for (var i = 0, len = array.length; i < len; i++) {
  1034. var cartographic = SuperMap3D.Cartographic.fromCartesian(array[i]);
  1035. var longitude = SuperMap3D.Math.toDegrees(cartographic.longitude);
  1036. var latitude = SuperMap3D.Math.toDegrees(cartographic.latitude);
  1037. var h = cartographic.height;
  1038. if (positions.indexOf(longitude) == -1 && positions.indexOf(latitude) == -1) {
  1039. positions.push(longitude);
  1040. positions.push(latitude);
  1041. positions.push(parseInt(dep));
  1042. positionsii.push({
  1043. x: longitude,
  1044. y: latitude
  1045. });
  1046. }
  1047. }
  1048. //此处用的地形修改 而不是地形开挖
  1049. that.viewer.scene.globe.removeAllModifyRegion();
  1050. that.viewer.scene.globe.addModifyRegion({
  1051. name: 'ggg',
  1052. position: positions
  1053. });
  1054. var length = [];
  1055. length.push(positionsii.length);
  1056. //需要在此 动态构造一个 REGION类型的对象
  1057. var geometry = {
  1058. "id": 23,
  1059. "parts": length,
  1060. "points": positionsii,
  1061. "style": null,
  1062. "type": "REGION"
  1063. };
  1064. var queryObj = {
  1065. "cutFillType": "REGIONANDALTITUDE",
  1066. "baseAltitude": dep,
  1067. "region": geometry,
  1068. "resultDataset": "result",
  1069. "buildPyramid": true,
  1070. "deleteExistResultDataset": true
  1071. };
  1072. var queryObjJSON = JSON.stringify(queryObj);
  1073. $.ajax({
  1074. type: 'post',
  1075. 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",
  1076. data: queryObjJSON,
  1077. success: function (data) {
  1078. console.log(data);
  1079. // var resultObj = JSON.parse(data);
  1080. var resultObj = data;
  1081. document.getElementById("cutarea").value = resultObj.cutArea;
  1082. document.getElementById("cutVolume").value = resultObj.cutVolume;
  1083. document.getElementById("fillarea").value = resultObj.fillArea;
  1084. document.getElementById("fillVolume").value = resultObj.fillVolume;
  1085. document.getElementById("remainderArea").value = resultObj.remainderArea;
  1086. }
  1087. });
  1088. });
  1089. document.getElementById("filladd").onclick = function () {
  1090. that.handlerExcavationAnalyze.activate();
  1091. };
  1092. document.getElementById("fillclear").onclick = function () {
  1093. that.viewer.scene.globe.removeAllModifyRegion();
  1094. document.getElementById("cutarea").value = "";
  1095. document.getElementById("cutVolume").value = "";
  1096. document.getElementById("fillarea").value = "";
  1097. document.getElementById("fillVolume").value = "";
  1098. document.getElementById("remainderArea").value = "";
  1099. that.handlerExcavationAnalyze.clear();
  1100. };
  1101. $('#excavationAnalyze').show();
  1102. $('#loadingbar').remove();
  1103. if (!that.viewer.scene.pickPositionSupported) {
  1104. alert('不支持深度拾取,无法进行鼠标交互绘制!');
  1105. }
  1106. }, 1000)
  1107. },
  1108. /**
  1109. * 切换地图
  1110. */
  1111. queryVectorTilesMapList(deptId) {
  1112. queryMap(deptId).then(req => { // from forestry_develop_2.0
  1113. //切换地图
  1114. req = req.sort(function(a, b) {
  1115. return a.sort - b.sort
  1116. })
  1117. this.queryList = req
  1118. this.onload(req)
  1119. })
  1120. },
  1121. //清除所有
  1122. clearAll() {
  1123. this.viewer.entities.removeAll()
  1124. this.viewer.scene.scanEffect.show = false
  1125. },
  1126. //移除之前添加的点
  1127. clearMRadius() {
  1128. if (this.markerboxEntityRadius != null && this.markerboxEntityRadius.length > 0) {
  1129. for (let i = 0; i < this.markerboxEntityRadius.length; i++) {
  1130. this.viewer.entities.remove(this.markerboxEntityRadius[i])
  1131. }
  1132. this.markerboxEntityRadius = []
  1133. }
  1134. },
  1135. //移除之前添加的线
  1136. clearTwoC() {
  1137. if (this.connectBoxEntityTwo != null) {
  1138. this.viewer.entities.remove(this.connectBoxEntityTwo)
  1139. this.connectBoxEntityTwo = null
  1140. }
  1141. },
  1142. /**
  1143. * 地图落点-覆盖范围
  1144. */
  1145. setMarkersRadius(makerList) {
  1146. let that = this
  1147. for (let i = 0; i < makerList.length; i++) {
  1148. let longitude = makerList[i].lng*1;
  1149. let latitude = makerList[i].lat*1;
  1150. let radius = makerList[i].radius*1;
  1151. let marker = that.viewer.entities.add({
  1152. name: "",
  1153. position: new SuperMap3D.Cartesian3.fromDegrees(longitude, latitude),
  1154. billboard: {
  1155. image: iconList[makerList[i].icon],
  1156. width: 48,
  1157. height: 48,
  1158. heightReference: SuperMap3D.HeightReference.CLAMP_TO_GROUND,
  1159. disableDepthTestDistance: Number.POSITIVE_INFINITY
  1160. },
  1161. description: makerList[i].bindPopupHtml,
  1162. click: makerList[i].click,
  1163. parameter: makerList[i].parameter
  1164. })
  1165. that.markerboxEntityRadius.push(marker)
  1166. //绘制摄像头的圈(覆盖范围)
  1167. // if(radius!=0){
  1168. // const markerRadius = that.viewer.entities.add({
  1169. // position: new SuperMap3D.Cartesian3.fromDegrees(longitude, latitude),
  1170. // ellipse: {
  1171. // semiMinorAxis: radius,
  1172. // semiMajorAxis: radius,
  1173. // material: SuperMap3D.Color.DODGERBLUE.withAlpha(0.4),
  1174. // outline: true, //是否显示边框
  1175. // outlineColor: SuperMap3D.Color.BLUE, //边框颜色
  1176. // outlineWidth: 1,
  1177. // heightReference: SuperMap3D.HeightReference.NONE
  1178. // },
  1179. // });
  1180. // that.markerboxEntityRadius.push(markerRadius)
  1181. // }
  1182. }
  1183. // that.createLeftClickDescription()
  1184. that.createRightClickDescription()
  1185. },
  1186. /**
  1187. * 地图画线(贴地)
  1188. */
  1189. setConnectTwoList(connectList, color, withAlpha) {
  1190. let that = this
  1191. //SuperMap3D.Color.fromCssColorString('#67ADDF') 16进制颜色设置
  1192. let material = SuperMap3D.Color.fromCssColorString(color).withAlpha(withAlpha)
  1193. that.connectBoxEntityTwo = that.viewer.entities.add({
  1194. Type: 'Polyline',
  1195. polyline: {
  1196. positions: new SuperMap3D.Cartesian3.fromDegreesArray(connectList),
  1197. clampToGround: true, //贴地 true,不贴地 false
  1198. width: 5,
  1199. material: material
  1200. }
  1201. })
  1202. },
  1203. //移除之前添加的点
  1204. clearM() {
  1205. if (this.markerboxEntity != null && this.markerboxEntity.length > 0) {
  1206. for (let i = 0; i < this.markerboxEntity.length; i++) {
  1207. this.viewer.entities.remove(this.markerboxEntity[i])
  1208. }
  1209. this.markerboxEntity = []
  1210. }
  1211. },
  1212. //移除之前添加的线
  1213. clearC() {
  1214. if (this.connectBoxEntity != null) {
  1215. this.viewer.entities.remove(this.connectBoxEntity)
  1216. this.connectBoxEntity = null
  1217. }
  1218. },
  1219. //移除之前添加的面
  1220. clearG() {
  1221. if (this.graphicsBoxEntity != null) {
  1222. this.viewer.entities.remove(this.graphicsBoxEntity)
  1223. this.graphicsBoxEntity = null
  1224. }
  1225. },
  1226. //移除之前添加的面
  1227. clearGList() {
  1228. for (let i = 0; i < this.graphicsBoxEntityList.length; i++) {
  1229. this.viewer.entities.remove(this.graphicsBoxEntityList[i])
  1230. }
  1231. this.graphicsBoxEntityList = []
  1232. },
  1233. lonAndLatPlacement(lon, lat) {
  1234. let that = this
  1235. if (that.positioningEntity != null) {
  1236. this.viewer.entities.remove(that.positioningEntity)
  1237. }
  1238. that.positioningEntity = that.viewer.entities.add({
  1239. name: "",
  1240. position: new SuperMap3D.Cartesian3.fromDegrees(lon, lat),
  1241. billboard: {
  1242. image: iconList['positioning'],
  1243. width: 48,
  1244. height: 48,
  1245. heightReference: SuperMap3D.HeightReference.CLAMP_TO_GROUND,
  1246. disableDepthTestDistance: Number.POSITIVE_INFINITY
  1247. }
  1248. })
  1249. },
  1250. setIsObtainLaAndLon(isObtainLaAndLon) {
  1251. this.isObtainLaAndLon = isObtainLaAndLon
  1252. },
  1253. clearDW() {
  1254. if (this.positioningEntity != null) {
  1255. this.viewer.entities.remove(this.positioningEntity);
  1256. }
  1257. },
  1258. flyTo(longitude, latitude, height) {
  1259. let that = this
  1260. setTimeout(function() {
  1261. that.viewer.camera.setView({
  1262. destination: new SuperMap3D.Cartesian3.fromDegrees(Number(longitude)+Number(0.1), Number(latitude)-Number(1.3), Number(140000)),
  1263. orientation: {
  1264. heading: SuperMap3D.Math.toRadians(0),
  1265. pitch: SuperMap3D.Math.toRadians(-45),
  1266. roll: 0
  1267. }
  1268. })
  1269. }, 3000)
  1270. },
  1271. openTvwall() {
  1272. this.mapshow = false
  1273. if (this.openZt) {
  1274. this.$emit('fatherMethod', this.dianshiqiang, this.longitude, this.latitude, this.userList)
  1275. } else {
  1276. this.$emit(this._click, this._parameter)
  1277. }
  1278. },
  1279. /**
  1280. * 地图落点
  1281. */
  1282. setMarkers(makerList) {
  1283. let that = this
  1284. clearInterval(that.aac)
  1285. for (let i in makerList) {
  1286. let longitude = makerList[i].lng
  1287. let latitude = makerList[i].lat
  1288. let marker = that.viewer.entities.add({
  1289. name: '',
  1290. position: new SuperMap3D.Cartesian3.fromDegrees(Number(longitude), Number(latitude)),
  1291. billboard: {
  1292. image: iconList[makerList[i].icon],
  1293. width: 48,
  1294. height: 48,
  1295. heightReference: SuperMap3D.HeightReference.CLAMP_TO_GROUND,
  1296. disableDepthTestDistance: Number.POSITIVE_INFINITY
  1297. },
  1298. description: makerList[i].bindPopupHtml,
  1299. click: makerList[i].click,
  1300. parameter: makerList[i].parameter
  1301. })
  1302. that.markerboxEntity.push(marker)
  1303. }
  1304. that.viewer.scene.globe.depthTestAgainstTerrain = false
  1305. // that.createLeftClickDescription()
  1306. that.createRightClickDescription()
  1307. },
  1308. /**
  1309. *鼠标左击事件是原来的气泡
  1310. */
  1311. createLeftClickDescription() {
  1312. let that = this
  1313. that.handler.setInputAction(function(movement) {
  1314. that.pick = that.viewer.scene.pick(movement.position)
  1315. if (that.pick && that.pick) {
  1316. let id = SuperMap3D.defaultValue(that.viewer.scene.pick(movement.position).id, that.viewer.scene.pick(
  1317. movement.position).primitive.id)
  1318. let html = id._description
  1319. if (html != undefined && html._value != null && html._value != '') {
  1320. that.bindPopupHtml = html
  1321. that.mapshow = true
  1322. that.openZt = false
  1323. that._click = id._click
  1324. that._parameter = id._parameter
  1325. } else {
  1326. that.mapshow = false
  1327. }
  1328. } else {
  1329. that.mapshow = false
  1330. }
  1331. }, SuperMap3D.ScreenSpaceEventType.LEFT_CLICK)
  1332. },
  1333. /**
  1334. *鼠标右击事件是原来的点击
  1335. */
  1336. createRightClickDescription() {
  1337. let that = this
  1338. that.handler.setInputAction(function(movement) {
  1339. that.mapshow = false
  1340. if (new Date().getTime() - that.clickTime < 2000) {
  1341. return
  1342. } else {
  1343. that.clickTime = new Date().getTime()
  1344. }
  1345. // 监听鼠标的当前位置坐标,然后根据当前坐标去动态更新气泡窗口div的显示位置;
  1346. that.pick = that.viewer.scene.pick(movement.position)
  1347. if (that.pick && that.pick) {
  1348. let id = SuperMap3D.defaultValue(that.viewer.scene.pick(movement.position).id, that.viewer.scene.pick(
  1349. movement.position).primitive.id)
  1350. let clickName = id._click
  1351. that.$emit(clickName, id._parameter)
  1352. }
  1353. }, SuperMap3D.ScreenSpaceEventType.LEFT_CLICK)
  1354. },
  1355. /**
  1356. * 落点定位
  1357. */
  1358. /**
  1359. * 落点定位
  1360. */
  1361. dropLocation(lat, lng, index,radius) {
  1362. this.viewer.scene.globe.depthTestAgainstTerrain = true;
  1363. this.viewer.camera.flyTo({
  1364. destination: new SuperMap3D.Cartesian3.fromDegrees(Number(lng), Number(lat)-Number(1.3), Number(140000)),
  1365. orientation: {
  1366. heading: SuperMap3D.Math.toRadians(0),
  1367. pitch: SuperMap3D.Math.toRadians(-45),
  1368. roll: 0
  1369. }
  1370. })
  1371. if (radius != undefined && radius != null) {
  1372. let that = this
  1373. // 初始化颜色选择控件
  1374. var initialScanColor = '#2263e6'
  1375. that.viewer.scene.scanEffect.color = SuperMap3D.Color.fromCssColorString(initialScanColor)
  1376. // 获取或设置扫描线的运行周期,单位:秒。
  1377. that.viewer.scene.scanEffect.period = radius / 500
  1378. // 获取或设置扫描线的运行速度,单位:米/秒。
  1379. that.viewer.scene.scanEffect.speed = 500
  1380. that.viewer.scene.scanEffect.mode = SuperMap3D.ScanEffectMode.CIRCLE
  1381. that.viewer.scene.scanEffect.centerPostion = new SuperMap3D.Cartesian3.fromDegrees(lng, lat, 3000)
  1382. that.viewer.scene.scanEffect.show = true
  1383. }
  1384. },
  1385. /**
  1386. * 地图画线(贴地)
  1387. */
  1388. setConnectList(connectList, color, withAlpha) {
  1389. let that = this
  1390. //SuperMap3D.Color.fromCssColorString('#67ADDF') 16进制颜色设置
  1391. let material = SuperMap3D.Color.fromCssColorString(color).withAlpha(withAlpha)
  1392. that.connectBoxEntity = that.viewer.entities.add({
  1393. Type: 'Polyline',
  1394. polyline: {
  1395. positions: new SuperMap3D.Cartesian3.fromDegreesArray(connectList),
  1396. clampToGround: true, //贴地 true,不贴地 false
  1397. width: 5,
  1398. material: material
  1399. }
  1400. })
  1401. },
  1402. /**
  1403. * 地图图形(贴地)
  1404. */
  1405. setGraphicsList(graphicsList, color, withAlpha) {
  1406. let that = this
  1407. //SuperMap3D.Color.fromCssColorString('#67ADDF') 16进制颜色设置
  1408. let material = SuperMap3D.Color.fromCssColorString(color).withAlpha(withAlpha)
  1409. that.graphicsBoxEntity = that.viewer.entities.add({
  1410. polygon: {
  1411. hierarchy: new SuperMap3D.Cartesian3.fromDegreesArray(graphicsList),
  1412. clampToGround: true, //贴地 true,不贴地 false
  1413. width: 5,
  1414. material: material
  1415. }
  1416. })
  1417. },
  1418. // 批量画面
  1419. setGraphicsLists(graphicsList, color, withAlpha) {
  1420. let that = this
  1421. let material = SuperMap3D.Color.fromCssColorString(color).withAlpha(withAlpha)
  1422. for (let i = 0; i < graphicsList.length; i++) {
  1423. let positions = new SuperMap3D.Cartesian3.fromDegreesArray(graphicsList[i].latLng)
  1424. let name = graphicsList[i].name.toString()
  1425. let center = SuperMap3D.BoundingSphere.fromPoints(positions).center
  1426. let namePosition = SuperMap3D.Cartographic.fromCartesian(center)
  1427. namePosition.height = 0 // 将名称高度设置为0,使其贴地显示
  1428. that.graphicsBoxEntityList.push(that.viewer.entities.add({
  1429. polygon: {
  1430. hierarchy: positions,
  1431. clampToGround: true,
  1432. width: 5,
  1433. material: material
  1434. },
  1435. position: center,
  1436. label: {
  1437. text: name,
  1438. font: 'Bold 12px sans-serif',
  1439. fillColor: SuperMap3D.Color.BLACK,
  1440. outlineColor: SuperMap3D.Color.WHITE,
  1441. outlineWidth: 2,
  1442. pixelOffset: new SuperMap3D.Cartesian2(0, 0),
  1443. heightReference: SuperMap3D.HeightReference.CLAMP_TO_GROUND,
  1444. disableDepthTestDistance: Number.POSITIVE_INFINITY
  1445. }
  1446. }))
  1447. }
  1448. }
  1449. }
  1450. }
  1451. </script>
  1452. <style rel="stylesheet/scss" lang="scss" scoped>
  1453. .map-tit {
  1454. position: absolute;
  1455. top: 90px;
  1456. left: 50%;
  1457. transform: translatex(-50%);
  1458. border: 1px solid #15519b;
  1459. z-index: 9999;
  1460. background: linear-gradient(rgba(4, 23, 62, 0.6), rgba(0, 28, 70, 0.6));
  1461. min-width: 300px;
  1462. .sj-icon-btn {
  1463. display: block;
  1464. margin: 10px auto 15px auto;
  1465. padding: 0px 16px;
  1466. font-size: 10px;
  1467. height: 1.7rem;
  1468. }
  1469. .top-tit {
  1470. width: 100%;
  1471. height: 28px;
  1472. line-height: 28px;
  1473. display: flex;
  1474. flex-direction: row;
  1475. justify-content: space-between;
  1476. background: #15519b80;
  1477. padding: 0px 10px;
  1478. align-items: center;
  1479. i {
  1480. color: #10ccff;
  1481. font-size: 18px;
  1482. text-shadow: 0px 0px 5px #23b3b3;;
  1483. }
  1484. span img {
  1485. display: block;
  1486. width: 12px;
  1487. height: 12px;
  1488. color: #fff;
  1489. cursor: pointer;
  1490. }
  1491. }
  1492. .map-txt {
  1493. padding: 10px 15px;
  1494. color: #fff;
  1495. line-height: 20px;
  1496. font-size: 12px;
  1497. .d-l-con {
  1498. }
  1499. }
  1500. }
  1501. .fade-enter-active,
  1502. .fade-leave-active {
  1503. transition: 1s;
  1504. }
  1505. .fade-enter,
  1506. .fade-leave-to {
  1507. opacity: 0;
  1508. transform: translateY(-10rem);
  1509. }
  1510. </style>