supermap-2.5d.vue 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055
  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>
  17. <div id="super2"></div>
  18. </transition>
  19. <!--地图top 显示 结束-->
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import {
  25. iconList,
  26. getDeviceList
  27. } from '@/api/components/supermap.js'
  28. import Cookies from 'js-cookie'
  29. import {
  30. getConfigKey
  31. } from "@/api/system/config";
  32. export default {
  33. name: 'supermap-2.5d',
  34. data() {
  35. return {
  36. _click:null,
  37. openZt: false,
  38. _parameter:null,
  39. bindPopupHtml: null,
  40. mapshow: false,
  41. superMapRootUrl: null,
  42. viewer: null,
  43. scene: null,
  44. handler: null,
  45. pick: null,
  46. back_position: null,
  47. content: null,
  48. mvtMap0: null,
  49. shuixi_name: null,
  50. mvtMap1: null,
  51. mvtMap2: null,
  52. mvtMap3: null,
  53. road_name: null,
  54. layer_xiangzhenjie_name: null,
  55. markerboxEntity: [], //地图落点实体
  56. connectBoxEntity: null, //地图线实体
  57. graphicsBoxEntity: null, //地图面实体
  58. markerboxEntityRadius: [], //地图落点实体
  59. connectBoxEntityTwo: null, //地图线实体
  60. /*************************原地图属性*********************/
  61. isEditableLayers: false, //绘图控件
  62. selOptV: 2, // 贴地量算
  63. clampMode: 1, // 空间模式
  64. handlerDis: null, // 距离
  65. handlerArea: null, // 面积
  66. /*************************原地图属性*********************/
  67. aac: null,
  68. queryParams: {
  69. name: null,
  70. mapData: null,
  71. mapName: null
  72. },
  73. clickTime: new Date().getTime(),
  74. cacheData: {
  75. ProvinceRoad: "",
  76. CountyRoad: "",
  77. StateRoad: "",
  78. ShuiXi: "",
  79. XianJie: "",
  80. XiangZhenJie: "",
  81. Cun: "",
  82. },
  83. supermapUrls: [
  84. [
  85. "/3D-sipingchangjing/rest/realspace/datas/siping_2m@spyx4326",//底图
  86. "/3D-local3DCache-0608XinBanQingXieShiJing/rest/realspace",//3D模型(二级图层)
  87. "/map-mvt-shuixiMian/restjsr/v1/vectortile/maps/shuixi_Mian",//水系图
  88. "/map-mvt-lindi/restjsr/v1/vectortile/maps/lindi",//林地图
  89. "/map-mvt-nongtian/restjsr/v1/vectortile/maps/nongtian",//农田图
  90. "/map-mvt-roadXian/restjsr/v1/vectortile/maps/road_Xian",//路网图
  91. "/3D-road_Name_S/rest/realspace",//路网名称
  92. "ProvinceRoad_L@SiPing#1",//名称图层叠加
  93. "CountyRoad_L@SiPing#1",//名称图层叠加
  94. "StateRoad_L@SiPing#1",//名称图层叠加
  95. "/3D-shuixi_Name/rest/realspace",//水系名称
  96. "ShuiXi@SiPing#1",//水系名称叠加
  97. "/map-SIPING/rest/maps/XianJie_XiangZhenJie",//乡镇街界限
  98. "/3D-Name_he/rest/realspace",//乡镇街名称
  99. "XianJie@SiPing#1",//县界名称
  100. "XiangZhenJie@SiPing#2",//乡镇街名称
  101. "Cun@SiPing#1",//村名称
  102. ],
  103. [
  104. "/3D-shuangliaoYX/rest/realspace/datas/siping_2m_shuangliao@spyx4326",
  105. "/3D-shuangliaoYX/rest/realspace/datas/shuangliao@spyx4326",
  106. "/map-mvt-shuiximianshuangliao/restjsr/v1/vectortile/maps/shuixi_mian_shuangliao",
  107. "/map-mvt-lindishuangliao/restjsr/v1/vectortile/maps/lindi_shuangliao",
  108. "/map-mvt-nongtianshuangliao/restjsr/v1/vectortile/maps/nongtian_shuangliao",
  109. "/map-mvt-roadxianshuangliao/restjsr/v1/vectortile/maps/road_xian_shuangliao",
  110. "/3D-road_Name_S_shuangliao/rest/realspace",
  111. "ProvinceRoad_L_shuangliao@Road#1",
  112. "CountyRoad_L_shuangliao@Road#1",
  113. "StateRoad_L_shuangliao@Road#1",
  114. "/3D-shuixi_Name_shuangliao/rest/realspace",
  115. "ShuiXi_shuangliao@Road#1",
  116. "/map-SIPING/rest/maps/xiangzhenjie_shuangliao",
  117. "/3D-Name_he_shuangliao/rest/realspace",
  118. "shuangliaoshi@gengdi#1",
  119. "XiangZhenJie_shuangliao@gengdi#1",
  120. "Cun_shuangliao@SiPing#1",
  121. ],
  122. [
  123. "/3D-lishuYX/rest/realspace/datas/siping_2m_lishu@spyx4326",
  124. "/3D-lishuYX/rest/realspace/datas/lishu_1@spyx4326",
  125. "/map-mvt-shuiximianlishu/restjsr/v1/vectortile/maps/shuixi_mian_lishu",
  126. "/map-mvt-lindilishu/restjsr/v1/vectortile/maps/lindi_lishu",
  127. "/map-mvt-nongtianlishu/restjsr/v1/vectortile/maps/nongtian_lishu",
  128. "/map-mvt-roadxianlishu/restjsr/v1/vectortile/maps/road_xian_lishu",
  129. "/3D-road_Name_S_lishu/rest/realspace",
  130. "ProvinceRoad_L_lishu@Road#1",
  131. "CountyRoad_L_lishu@Road#1",
  132. "StateRoad_L_lishu@Road#1",
  133. "/3D-shuixi_Name_lishu/rest/realspace",
  134. "ShuiXi_lishu@Road#1",
  135. "/map-SIPING/rest/maps/xiangzhenjie_lishu",
  136. "/3D-Name_he_lishu/rest/realspace",
  137. "lishushi@gengdi#1",
  138. "XiangZhenJie_lishu@gengdi#1",
  139. "Cun_lishu@SiPing#1",
  140. ],
  141. [
  142. "/3D-tiexiYX/rest/realspace/datas/siping_2m_tiexi@spyx4326",
  143. "/3D-local3DCache-0608XinBanQingXieShiJing/rest/realspace",
  144. "/map-mvt-shuiximiantiexi/restjsr/v1/vectortile/maps/shuixi_mian_tiexi",
  145. "/map-mvt-linditiexi/restjsr/v1/vectortile/maps/lindi_tiexi",
  146. "/map-mvt-nongtiantiexi/restjsr/v1/vectortile/maps/nongtian_tiexi",
  147. "/map-mvt-roadxiantiexi/restjsr/v1/vectortile/maps/road_xian_tiexi",
  148. "/3D-road_Name_S_tiexi/rest/realspace",
  149. "ProvinceRoad_L_tiexi@Road#1",
  150. "CountyRoad_L_tiexi@Road#1",
  151. "StateRoad_L_tiexi@Road#1",
  152. "/3D-shuixi_Name_tiexi/rest/realspace",
  153. "ShuiXi_tiexi@Road#1",
  154. "/map-SIPING/rest/maps/xiangzhenjie_tiexi",
  155. "/3D-Name_he_tiexi/rest/realspace",
  156. "tiexishi@gengdi#1",
  157. "XiangZhenJie_tiexi@gengdi#1",
  158. "Cun_tiexi@SiPing#1",
  159. ],
  160. [
  161. "/3D-tiedongYX/rest/realspace/datas/siping_2m_tiedong@spyx4326",
  162. "/3D-tiedongYX/rest/realspace/datas/tiedong@spyx4326",
  163. "/map-mvt-shuiximiantiedong/restjsr/v1/vectortile/maps/shuixi_mian_tiedong",
  164. "/map-mvt-linditiedong/restjsr/v1/vectortile/maps/lindi_tiedong",
  165. "/map-mvt-nongtiantiedong/restjsr/v1/vectortile/maps/nongtian_tiedong",
  166. "/map-mvt-roadxiantiedong/restjsr/v1/vectortile/maps/road_xian_tiedong",
  167. "/3D-road_Name_S_tiedong/rest/realspace",
  168. "ProvinceRoad_L_tiedong@Road#1",
  169. "CountyRoad_L_tiedong@Road#1",
  170. "StateRoad_L_tiedong@Road#1",
  171. "/3D-shuixi_Name_tiedong/rest/realspace",
  172. "ShuiXi_tiedong@Road#1",
  173. "/map-SIPING/rest/maps/xiangzhenjie_tiedong",
  174. "/3D-Name_he_tiedong/rest/realspace",
  175. "tiedongshi@gengdi#1",
  176. "XiangZhenJie_tiedong@gengdi#1",
  177. "Cun_tiedong@SiPing#1",
  178. ],
  179. [
  180. "/3D-yitongYX/rest/realspace/datas/siping_2m_yitong@spyx4326",
  181. "/3D-yitongYX/rest/realspace/datas/yitong@spyx4326",
  182. "/map-mvt-shuiximianyitong/restjsr/v1/vectortile/maps/shuixi_mian_yitong",
  183. "/map-mvt-lindiyitong/restjsr/v1/vectortile/maps/lindi_yitong",
  184. "/map-mvt-nongtianyitong/restjsr/v1/vectortile/maps/nongtian_yitong",
  185. "/map-mvt-roadxianyitong/restjsr/v1/vectortile/maps/road_xian_yitong",
  186. "/3D-road_Name_S_yitong/rest/realspace",
  187. "ProvinceRoad_L_yitong@Road#1",
  188. "CountyRoad_L_yitong@Road#1",
  189. "StateRoad_L_yitong@Road#1",
  190. "/3D-shuixi_Name_yitong/rest/realspace",
  191. "ShuiXi_yitong@Road#1",
  192. "/map-SIPING/rest/maps/xiangzhenjie_yitong",
  193. "/3D-Name_he_yitong/rest/realspace",
  194. "yitongshi@gengdi#1",
  195. "XiangZhenJie_yitong@gengdi#1",
  196. "Cun_yitong@SiPing#1",
  197. ],
  198. ],
  199. dianshiqiang:null,
  200. longitude:null,
  201. latitude:null,
  202. userList:null,
  203. }
  204. },
  205. watch: {},
  206. created() {
  207. },
  208. mounted() {},
  209. props: {},
  210. methods: {
  211. //初始化地图数据
  212. removeAllviewer(num, index) {
  213. if (index != -1) {
  214. $('#cesiumContainer').remove();
  215. $('#supermap3D').append("<div id=\"cesiumContainer\" style=\"width: 100%; height: 100%;background: none;\" >\n" +
  216. " </div>")
  217. }
  218. let that = this;
  219. // that.removeAllMvt();
  220. // that.viewer.imageryLayers.remove(this.layer);
  221. // that.road_name.then(function (layers) {
  222. // that.viewer.scene.layers.find(that.cacheData.XianJie).visible = false;//文字图层
  223. // that.viewer.scene.layers.find(that.cacheData.XiangZhenJie).visible = false;//文字图层
  224. // that.viewer.scene.layers.find(that.cacheData.Cun).visible = false;//文字图层
  225. // });
  226. // that.layer_xianjie.show=false;
  227. that.superMapInfo(num);
  228. },
  229. choseMeasuringAreaAll() {
  230. if (this.handlerDis != null) {
  231. this.handlerDis.clear()
  232. }
  233. if (this.handlerArea != null) {
  234. this.handlerArea.clear()
  235. }
  236. },
  237. // 测量距离
  238. choseMeasuringDistance() {
  239. let that = this
  240. if (that.handlerDis != null) {
  241. that.handlerDis.deactivate()
  242. that.handlerDis.clear()
  243. }
  244. //初始化测量距离
  245. that.handlerDis = new Cesium.MeasureHandler(that.viewer, Cesium.MeasureMode.Distance, that.clampMode);
  246. that.handlerDis.clampMode = 1;
  247. //注册测距功能事件
  248. that.handlerDis.measureEvt.addEventListener(function(result) {
  249. var dis = Number(result.distance);
  250. var selOptV = that.selOptV;
  251. if (selOptV == 3 || selOptV == 4) {
  252. dis = Number(calcClampDistance(positions));
  253. };
  254. var distance = dis > 1000 ? (dis / 1000).toFixed(2) + 'km' : dis.toFixed(2) + 'm';
  255. that.handlerDis.disLabel.text = '距离:' + distance;
  256. });
  257. that.handlerDis.activeEvt.addEventListener(function(isActive) {
  258. if (isActive == true) {
  259. that.viewer.enableCursorStyle = false;
  260. that.viewer._element.style.cursor = '';
  261. $('#super2').removeClass('measureCur').addClass('measureCur');
  262. that.viewer.scene.pickPointEnabled = false;
  263. } else {
  264. that.viewer.enableCursorStyle = true;
  265. $('#super2').removeClass('measureCur');
  266. that.viewer.scene.pickPointEnabled = false;
  267. }
  268. });
  269. that.handlerDis.activate();
  270. },
  271. // 测量面积
  272. choseMeasuringArea() {
  273. let that = this
  274. if (that.handlerArea != null) {
  275. // that.handlerArea.deactivate()
  276. that.handlerArea.clear()
  277. }
  278. //初始化测量面积
  279. that.handlerArea = new Cesium.MeasureHandler(that.viewer, Cesium.MeasureMode.Area, that.clampMode);
  280. that.handlerArea.clampMode = 1;
  281. that.handlerArea.measureEvt.addEventListener(function(result) {
  282. var mj = Number(result.area);
  283. var area = mj > 1000000 ? (mj / 1000000).toFixed(2) + 'km²' : mj.toFixed(2) + '㎡'
  284. that.handlerArea.areaLabel.text = '面积:' + area;
  285. });
  286. that.handlerArea.activeEvt.addEventListener(function(isActive) {
  287. if (isActive == true) {
  288. that.viewer.enableCursorStyle = false;
  289. that.viewer._element.style.cursor = '';
  290. $('#super2').removeClass('measureCur').addClass('measureCur');
  291. that.viewer.scene.pickPointEnabled = false;
  292. } else {
  293. that.viewer.enableCursorStyle = true;
  294. that.viewer._element.style.cursor = '';
  295. $('#super2').removeClass('measureCur');
  296. that.viewer.scene.pickPointEnabled = false;
  297. }
  298. });
  299. that.handlerArea.activate();
  300. },
  301. //清除所有
  302. clearAll() {
  303. this.viewer.entities.removeAll()
  304. },
  305. //移除之前添加的点
  306. clearMRadius() {
  307. if (this.markerboxEntityRadius != null && this.markerboxEntityRadius.length > 0) {
  308. for (let i = 0; i < this.markerboxEntityRadius.length; i++) {
  309. this.viewer.entities.remove(this.markerboxEntityRadius[i])
  310. }
  311. this.markerboxEntityRadius = []
  312. }
  313. },
  314. mapShow() {
  315. this.mapshow = false,
  316. clearInterval(this.timer)
  317. },
  318. //移除之前添加的线
  319. clearTwoC() {
  320. if (this.connectBoxEntityTwo != null) {
  321. this.viewer.entities.remove(this.connectBoxEntityTwo)
  322. this.connectBoxEntityTwo = null
  323. }
  324. },
  325. /**
  326. * 地图落点-覆盖范围
  327. */
  328. setMarkersRadius(makerList) {
  329. let that = this
  330. that.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)
  331. for (let i in makerList) {
  332. let longitude = makerList[i].lng;
  333. let latitude = makerList[i].lat;
  334. let marker = that.viewer.entities.add({
  335. name: "",
  336. position: Cesium.Cartesian3.fromDegrees(longitude, latitude),
  337. billboard: {
  338. image: iconList[makerList[i].icon],
  339. width: 48,
  340. height: 48,
  341. heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
  342. disableDepthTestDistance: Number.POSITIVE_INFINITY
  343. },
  344. description: makerList[i].bindPopupHtml,
  345. click: makerList[i].click,
  346. parameter: makerList[i].parameter
  347. })
  348. that.markerboxEntityRadius.push(marker)
  349. //绘制摄像头的圈(覆盖范围)
  350. let markerRadius = that.viewer.entities.add({
  351. position: Cesium.Cartesian3.fromDegrees(makerList[i].lng, makerList[i].lat, 2),
  352. ellipse: {
  353. semiMinorAxis: makerList[i].radius,
  354. semiMajorAxis: makerList[i].radius,
  355. height: 0.0,
  356. material: Cesium.Color.DODGERBLUE.withAlpha(0.4),
  357. outline: true,
  358. outlineColor: Cesium.Color.DEEPSKYBLUE.withAlpha(1),
  359. outlineWidth: 1,
  360. },
  361. });
  362. that.markerboxEntityRadius.push(markerRadius)
  363. }
  364. that.viewer.scene.globe.depthTestAgainstTerrain = false
  365. that.createLeftClickDescription()
  366. that.createRightClickDescription()
  367. },
  368. /**
  369. * 地图画线(贴地)
  370. */
  371. setConnectTwoList(connectList, color, withAlpha) {
  372. let that = this
  373. //Cesium.Color.fromCssColorString('#67ADDF') 16进制颜色设置
  374. let material = Cesium.Color.fromCssColorString(color).withAlpha(withAlpha);
  375. that.connectBoxEntityTwo = that.viewer.entities.add({
  376. Type: 'Polyline',
  377. polyline: {
  378. positions: Cesium.Cartesian3.fromDegreesArray(connectList),
  379. clampToGround: true, //贴地 true,不贴地 false
  380. width: 5,
  381. material: material
  382. }
  383. })
  384. },
  385. //移除之前添加的点
  386. clearM() {
  387. if (this.markerboxEntity != null && this.markerboxEntity.length > 0) {
  388. for (let i = 0; i < this.markerboxEntity.length; i++) {
  389. this.viewer.entities.remove(this.markerboxEntity[i])
  390. }
  391. this.markerboxEntity = []
  392. }
  393. },
  394. //移除之前添加的线
  395. clearC() {
  396. if (this.connectBoxEntity != null) {
  397. this.viewer.entities.remove(this.connectBoxEntity)
  398. this.connectBoxEntity = null
  399. }
  400. },
  401. //移除之前添加的面
  402. clearG() {
  403. if (this.graphicsBoxEntity != null) {
  404. this.viewer.entities.remove(this.graphicsBoxEntity)
  405. this.graphicsBoxEntity = null
  406. }
  407. },
  408. superMapInfo(index) {
  409. getConfigKey('superMap.iServer').then(response => {
  410. this.superMapRootUrl = response.msg;
  411. this.onload(index);
  412. })
  413. },
  414. onload(index) {
  415. let that = this;
  416. const withinData = this.supermapUrls[index];
  417. //1.添加地形数据
  418. that.viewer = new Cesium.Viewer('cesiumContainer', {
  419. //创建地形服务提供者的实例,url为SuperMap iServer发布的TIN地形服务
  420. terrainProvider: new Cesium.CesiumTerrainProvider({
  421. url: that.superMapRootUrl + "/3D-sipingchangjing/rest/realspace/datas/dem@spyx4326",
  422. //isSct : false,//地形服务源自SuperMap iServer发布时需设置isSct为true
  423. invisibility: true
  424. }),
  425. infoBox: false,
  426. navigation: false
  427. }, {
  428. contextOptions: {
  429. msaaLevel: 4,
  430. requestWebgl2: true
  431. },
  432. orderIndependentTranslucency: false
  433. });
  434. that.scene = that.viewer.scene;
  435. that.viewer.cesiumWidget.creditContainer.style.display = "none" // 去掉超图logo水印
  436. //2.添加SuperMap iServer发布的影像服务
  437. let layer = that.viewer.imageryLayers.addImageryProvider(new Cesium.SuperMapImageryProvider({
  438. url: that.superMapRootUrl + withinData[0],
  439. }));
  440. if (index == 0) { //全部
  441. //飞行值坐标点,每3秒推进一级
  442. //heading-代表镜头左右方向,正值为右,负值为左
  443. //pitch-代表镜头上下方向,正值为上,负值为下.
  444. //roll-代表镜头左右倾斜,正值,向右倾斜,负值向左倾斜
  445. setTimeout(function () {
  446. that.viewer.camera.flyTo({
  447. destination: Cesium.Cartesian3.fromDegrees(124.49980650138238, 43.428263986216815, 950000),
  448. orientation: {
  449. // heading : Cesium.Math.toRadians(346.4202942851978),
  450. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  451. // roll : Cesium.Math.toRadians(0)
  452. }
  453. });
  454. }, 3000);
  455. setTimeout(function () {
  456. that.viewer.camera.flyTo({
  457. destination: Cesium.Cartesian3.fromDegrees(124.49980650138238, 43.428263986216815, 650000),
  458. orientation: {
  459. // heading : Cesium.Math.toRadians(346.4202942851978),
  460. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  461. // roll : Cesium.Math.toRadians(0)
  462. }
  463. });
  464. }, 3000);
  465. setTimeout(function () {
  466. that.viewer.camera.flyTo({
  467. destination: Cesium.Cartesian3.fromDegrees(124.49980650138238, 43.428263986216815, 350000),
  468. orientation: {
  469. // heading : Cesium.Math.toRadians(346.4202942851978),
  470. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  471. // roll : Cesium.Math.toRadians(0)
  472. }
  473. });
  474. }, 3000);
  475. } else if (index == 1) { //双辽
  476. //飞行值坐标点,每3秒推进一级
  477. //heading-代表镜头左右方向,正值为右,负值为左
  478. //pitch-代表镜头上下方向,正值为上,负值为下.
  479. //roll-代表镜头左右倾斜,正值,向右倾斜,负值向左倾斜
  480. setTimeout(function () {
  481. that.viewer.camera.flyTo({
  482. destination: Cesium.Cartesian3.fromDegrees(123.77896424451833, 43.70521317451045, 950000),
  483. orientation: {
  484. // heading : Cesium.Math.toRadians(346.4202942851978),
  485. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  486. // roll : Cesium.Math.toRadians(0)
  487. }
  488. });
  489. }, 3000);
  490. setTimeout(function () {
  491. that.viewer.camera.flyTo({
  492. destination: Cesium.Cartesian3.fromDegrees(123.77896424451833, 43.70521317451045, 650000),
  493. orientation: {
  494. // heading : Cesium.Math.toRadians(346.4202942851978),
  495. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  496. // roll : Cesium.Math.toRadians(0)
  497. }
  498. });
  499. }, 3000);
  500. setTimeout(function () {
  501. that.viewer.camera.flyTo({
  502. destination: Cesium.Cartesian3.fromDegrees(123.77896424451833, 43.70521317451045, 200000),
  503. orientation: {
  504. // heading : Cesium.Math.toRadians(346.4202942851978),
  505. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  506. // roll : Cesium.Math.toRadians(0)
  507. }
  508. });
  509. }, 3000);
  510. } else if (index == 2) { //梨树
  511. //飞行值坐标点,每3秒推进一级
  512. //heading-代表镜头左右方向,正值为右,负值为左
  513. //pitch-代表镜头上下方向,正值为上,负值为下.
  514. //roll-代表镜头左右倾斜,正值,向右倾斜,负值向左倾斜
  515. setTimeout(function () {
  516. that.viewer.camera.flyTo({
  517. destination: Cesium.Cartesian3.fromDegrees(124.28276991763133, 43.46361757293432, 950000),
  518. orientation: {
  519. // heading : Cesium.Math.toRadians(346.4202942851978),
  520. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  521. // roll : Cesium.Math.toRadians(0)
  522. }
  523. });
  524. }, 3000);
  525. setTimeout(function () {
  526. that.viewer.camera.flyTo({
  527. destination: Cesium.Cartesian3.fromDegrees(124.28276991763133, 43.46361757293432, 650000),
  528. orientation: {
  529. // heading : Cesium.Math.toRadians(346.4202942851978),
  530. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  531. // roll : Cesium.Math.toRadians(0)
  532. }
  533. });
  534. }, 3000);
  535. setTimeout(function () {
  536. that.viewer.camera.flyTo({
  537. destination: Cesium.Cartesian3.fromDegrees(124.28276991763133, 43.46361757293432, 200000),
  538. orientation: {
  539. // heading : Cesium.Math.toRadians(346.4202942851978),
  540. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  541. // roll : Cesium.Math.toRadians(0)
  542. }
  543. });
  544. }, 3000);
  545. } else if (index == 3) { //铁西
  546. //飞行值坐标点,每3秒推进一级
  547. //heading-代表镜头左右方向,正值为右,负值为左
  548. //pitch-代表镜头上下方向,正值为上,负值为下.
  549. //roll-代表镜头左右倾斜,正值,向右倾斜,负值向左倾斜
  550. setTimeout(function () {
  551. that.viewer.camera.flyTo({
  552. destination: Cesium.Cartesian3.fromDegrees(124.35516104252032, 43.220384847557234, 1050000),
  553. orientation: {
  554. // heading : Cesium.Math.toRadians(346.4202942851978),
  555. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  556. // roll : Cesium.Math.toRadians(0)
  557. }
  558. });
  559. }, 3000);
  560. setTimeout(function () {
  561. that.viewer.camera.flyTo({
  562. destination: Cesium.Cartesian3.fromDegrees(124.35516104252032, 43.220384847557234, 550000),
  563. orientation: {
  564. // heading : Cesium.Math.toRadians(346.4202942851978),
  565. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  566. // roll : Cesium.Math.toRadians(0)
  567. }
  568. });
  569. }, 3000);
  570. setTimeout(function () {
  571. that.viewer.camera.flyTo({
  572. destination: Cesium.Cartesian3.fromDegrees(124.35516104252032, 43.220384847557234, 50000),
  573. orientation: {
  574. // heading : Cesium.Math.toRadians(346.4202942851978),
  575. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  576. // roll : Cesium.Math.toRadians(0)
  577. }
  578. });
  579. }, 3000);
  580. } else if (index == 4) { //铁东
  581. //飞行值坐标点,每3秒推进一级
  582. //heading-代表镜头左右方向,正值为右,负值为左
  583. //pitch-代表镜头上下方向,正值为上,负值为下.
  584. //roll-代表镜头左右倾斜,正值,向右倾斜,负值向左倾斜
  585. setTimeout(function () {
  586. that.viewer.camera.flyTo({
  587. destination: Cesium.Cartesian3.fromDegrees(124.54435750508439, 43.04539078139383, 950000),
  588. orientation: {
  589. // heading : Cesium.Math.toRadians(346.4202942851978),
  590. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  591. // roll : Cesium.Math.toRadians(0)
  592. }
  593. });
  594. }, 3000);
  595. setTimeout(function () {
  596. that.viewer.camera.flyTo({
  597. destination: Cesium.Cartesian3.fromDegrees(124.54435750508439, 43.04539078139383, 650000),
  598. orientation: {
  599. // heading : Cesium.Math.toRadians(346.4202942851978),
  600. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  601. // roll : Cesium.Math.toRadians(0)
  602. }
  603. });
  604. }, 3000);
  605. setTimeout(function () {
  606. that.viewer.camera.flyTo({
  607. destination: Cesium.Cartesian3.fromDegrees(124.54435750508439, 43.04539078139383, 100000),
  608. orientation: {
  609. // heading : Cesium.Math.toRadians(346.4202942851978),
  610. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  611. // roll : Cesium.Math.toRadians(0)
  612. }
  613. });
  614. }, 3000);
  615. } else if (index == 5) { //伊通
  616. //飞行值坐标点,每3秒推进一级
  617. //heading-代表镜头左右方向,正值为右,负值为左
  618. //pitch-代表镜头上下方向,正值为上,负值为下.
  619. //roll-代表镜头左右倾斜,正值,向右倾斜,负值向左倾斜
  620. setTimeout(function () {
  621. that.viewer.camera.flyTo({
  622. destination: Cesium.Cartesian3.fromDegrees(125.34420717245336, 43.35653920782364, 950000),
  623. orientation: {
  624. // heading : Cesium.Math.toRadians(346.4202942851978),
  625. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  626. // roll : Cesium.Math.toRadians(0)
  627. }
  628. });
  629. }, 3000);
  630. setTimeout(function () {
  631. that.viewer.camera.flyTo({
  632. destination: Cesium.Cartesian3.fromDegrees(125.34420717245336, 43.35653920782364, 650000),
  633. orientation: {
  634. // heading : Cesium.Math.toRadians(346.4202942851978),
  635. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  636. // roll : Cesium.Math.toRadians(0)
  637. }
  638. });
  639. }, 3000);
  640. setTimeout(function () {
  641. that.viewer.camera.flyTo({
  642. destination: Cesium.Cartesian3.fromDegrees(125.34420717245336, 43.35653920782364, 150000),
  643. orientation: {
  644. // heading : Cesium.Math.toRadians(346.4202942851978),
  645. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  646. // roll : Cesium.Math.toRadians(0)
  647. }
  648. });
  649. }, 3000);
  650. }
  651. //开始加载专题图等数据,8秒后开始执行
  652. setTimeout(function() {
  653. // // 3.水系
  654. // let shuixi = that.superMapRootUrl+"/map-mvt-shuixiMian/restjsr/v1/vectortile/maps/shuixi_Mian";
  655. // that.mvtMap0 = that.scene.addVectorTilesMap({
  656. // url: shuixi,
  657. // canvasWidth: 512,
  658. // name: 'mvt_map0',
  659. // viewer: that.viewer,
  660. // selectedColor:new Cesium.Color(6,169,254,0.5),
  661. // show:true,
  662. // });
  663. // //4.林地
  664. // let lindi = that.superMapRootUrl+"/map-mvt-lindi/restjsr/v1/vectortile/maps/lindi";
  665. // that.mvtMap1 = that.scene.addVectorTilesMap({
  666. // url: lindi,
  667. // canvasWidth: 512,
  668. // name: 'mvt_map1',
  669. // viewer: that.viewer,
  670. // selectedColor:new Cesium.Color(6,254,181,0.5),
  671. // show:true,
  672. // });
  673. //
  674. // //5.农田
  675. // let nongtian = that.superMapRootUrl+"/map-mvt-nongtian/restjsr/v1/vectortile/maps/nongtian";
  676. // that.mvtMap2 = that.scene.addVectorTilesMap({
  677. // url: nongtian,
  678. // canvasWidth: 512,
  679. // name: 'mvt_map2',
  680. // viewer: that.viewer,
  681. // selectedColor:new Cesium.Color(250, 236, 246,1.0),
  682. // show:true,
  683. // });
  684. //
  685. // //6.路网
  686. // let road = that.superMapRootUrl+"/map-mvt-roadXian/restjsr/v1/vectortile/maps/road_Xian";
  687. // that.mvtMap3 = that.scene.addVectorTilesMap({
  688. // url: road,
  689. // canvasWidth: 512,
  690. // name: 'mvt_map3',
  691. // viewer: that.viewer,
  692. // show:true,
  693. // });
  694. //
  695. // //7.添加路网NAME
  696. // let road_name_url = that.superMapRootUrl+'/3D-road_Name_S/rest/realspace';
  697. // that.road_name = that.scene.open(road_name_url);
  698. //
  699. // // 8.添加水系NAME
  700. // let shuixi_name_url = that.superMapRootUrl+'/3D-shuixi_Name/rest/realspace';
  701. // that.shuixi_name = that.scene.open(shuixi_name_url);
  702. //9.添加县界和乡镇界
  703. let layer_xianjie = that.viewer.imageryLayers.addImageryProvider(new Cesium.SuperMapImageryProvider({
  704. url: that.superMapRootUrl + withinData[12],
  705. }));
  706. //10.添加区县乡镇村名称
  707. let layer_xiangzhenjie_name = that.superMapRootUrl + withinData[13];
  708. that.scene.open(layer_xiangzhenjie_name);
  709. that.cacheData.XianJie = withinData[14]
  710. that.cacheData.XiangZhenJie = withinData[15]
  711. that.cacheData.Cun = withinData[16]
  712. that.road_name.then(function (layers) {
  713. let xianJie_textLayer = that.scene.layers.find(withinData[14]);//区县文字图层
  714. let xiangZhenJie_textLayer = that.scene.layers.find(withinData[15]);//乡镇文字图层
  715. let cun_textLayer = that.scene.layers.find(withinData[16]);//村文字图层
  716. //关闭避让
  717. xianJie_textLayer.isOverlapDisplayed = true;
  718. xiangZhenJie_textLayer.isOverlapDisplayed = true;
  719. cun_textLayer.isOverlapDisplayed = true;
  720. });
  721. }, 3000);
  722. that.viewer.selectedEntityChanged.addEventListener(function (entity) {
  723. if (entity != undefined && Reflect.has(entity, 'layerID')) {
  724. that.queryParams.name = entity.pickResult[entity.layerID][0].feature.properties.Name;
  725. that.queryParams.mapData = entity.pickResult[entity.layerID][0].feature.properties.SmUserID;
  726. that.queryParams.mapName = entity.pickResult[entity.layerID][0].feature.properties.layer;
  727. getDeviceList(that.queryParams).then(res => {
  728. const treeLabels = [{
  729. "id": null,
  730. "labelCode": "999",
  731. "labelName": "电视墙",
  732. "cameraType": null,
  733. "parentLabelCode": ""
  734. }];
  735. const labelChannels = [];
  736. for (let i in res.data) {
  737. treeLabels.push({
  738. "id": null,
  739. "labelCode": res.data[i].cameraCode,
  740. "labelName": res.data[i].cameraName,
  741. "cameraType": "1",
  742. "parentLabelCode": "999"
  743. })
  744. labelChannels.push({
  745. "labelCode": res.data[i].cameraCode,
  746. "channelDates": [
  747. {
  748. "channelCode": res.data[i].cameraCode,
  749. "channelName": res.data[i].cameraName,
  750. "channelSn": null,
  751. "cameraType": "1",
  752. "online": "1",
  753. "cameraCode": "1"
  754. }
  755. ]
  756. })
  757. }
  758. that.dianshiqiang = [
  759. {
  760. "switchTab": "2",
  761. "treeLabels": treeLabels,
  762. "labelChannels": labelChannels
  763. }
  764. ]
  765. that.longitude = res.data[0].longitude;
  766. that.latitude = res.data[0].latitude;
  767. that.userList = res.data[0].userList;
  768. let html =
  769. '<div class="map-tip">' +
  770. "<span>" +
  771. ' <div class="d-l-con">' +
  772. ' <div class="d-l-l-text">' +
  773. " <h4>名称:" + res.data[0].name +
  774. "</h4>" +
  775. " </div>" +
  776. " </div>" +
  777. " </span>";
  778. for (let i in res.data[0].userList){
  779. html += "<span>" +
  780. ' <div class="d-l-con">' +
  781. ' <div class="d-l-l-text">' +
  782. " <h4>" +res.data[0].userList[i].position+":"+res.data[0].userList[i].name+"</h4>" +
  783. " </div>" +
  784. " </div>" +
  785. " </span>"+
  786. "<span>" +
  787. ' <div class="d-l-con">' +
  788. ' <div class="d-l-l-text">' +
  789. " <h4>电话:" + (res.data[0].userList[i].phone ? res.data[0].userList[i].phone : "")+"</h4>" +
  790. " </div>" +
  791. " </div>" +
  792. " </span>";
  793. }
  794. html += "</div>";
  795. that.bindPopupHtml = html;
  796. that.mapshow = true
  797. });
  798. }
  799. });
  800. },
  801. openTvwall(){
  802. this.mapshow=false;
  803. if(this.openZt){
  804. this.$emit('fatherMethod', this.dianshiqiang, this.longitude, this.latitude, this.userList);
  805. }else{
  806. this.$emit(this._click,this._parameter);
  807. }
  808. },
  809. /**
  810. * 地图落点
  811. */
  812. setMarkers(makerList) {
  813. let that = this
  814. that.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)
  815. clearInterval(that.aac)
  816. for (let i in makerList) {
  817. let longitude = makerList[i].lng
  818. let latitude = makerList[i].lat
  819. let marker = that.viewer.entities.add({
  820. name: '',
  821. position: Cesium.Cartesian3.fromDegrees(longitude, latitude),
  822. billboard: {
  823. image: iconList[makerList[i].icon],
  824. width: 48,
  825. height: 48,
  826. heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
  827. disableDepthTestDistance: Number.POSITIVE_INFINITY
  828. },
  829. description: makerList[i].bindPopupHtml,
  830. click: makerList[i].click,
  831. parameter: makerList[i].parameter
  832. })
  833. that.markerboxEntity.push(marker)
  834. }
  835. that.viewer.scene.globe.depthTestAgainstTerrain = false
  836. that.createLeftClickDescription()
  837. that.createRightClickDescription()
  838. },
  839. /**
  840. *鼠标左击事件是原来的气泡
  841. */
  842. /**
  843. *鼠标左击事件是原来的气泡
  844. */
  845. createLeftClickDescription() {
  846. let that = this;
  847. that.handler.setInputAction(function(movement) {
  848. that.pick = that.viewer.scene.pick(movement.position);
  849. if (that.pick && that.pick) {
  850. let id = Cesium.defaultValue(that.viewer.scene.pick(movement.position).id, that.viewer.scene.pick(
  851. movement.position).primitive.id);
  852. let html = id._description;
  853. clearInterval(that.timer)
  854. if (html != undefined && html._value != null && html._value != '' && html != 'cgq') {
  855. that.bindPopupHtml = html
  856. that.mapshow = true
  857. that.openZt=false
  858. that._click = id._click;
  859. that._parameter = id._parameter;
  860. } else if (html == 'cgq') {
  861. that.timer = setInterval(function() {
  862. var color = "green";
  863. var value = Math.random();
  864. var up = "▲";
  865. var down = "▼";
  866. if (value > 0.5) {
  867. color = "red";
  868. value = value + "" + up;
  869. } else {
  870. value = value + "" + down;
  871. }
  872. that.bindPopupHtml = "<span style='color:" + color + "'>当前传感器数值: " + value + "</span>";
  873. }, 1000)
  874. that.mapshow = true
  875. } else {
  876. that.mapshow = false
  877. clearInterval(that.timer)
  878. }
  879. } else {
  880. that.mapshow = false
  881. clearInterval(that.timer)
  882. }
  883. }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
  884. },
  885. /**
  886. *鼠标右击事件是原来的点击
  887. */
  888. createRightClickDescription() {
  889. let that = this;
  890. that.handler.setInputAction(function(movement) {
  891. that.mapshow = false
  892. if (new Date().getTime() - that.clickTime < 2000) {
  893. return
  894. } else {
  895. that.clickTime = new Date().getTime()
  896. }
  897. // 监听鼠标的当前位置坐标,然后根据当前坐标去动态更新气泡窗口div的显示位置;
  898. that.pick = that.viewer.scene.pick(movement.position);
  899. if (that.pick && that.pick) {
  900. let id = Cesium.defaultValue(that.viewer.scene.pick(movement.position).id, that.viewer.scene.pick(
  901. movement.position).primitive.id);
  902. let clickName = id._click;
  903. that.$emit(clickName, id._parameter)
  904. }
  905. }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
  906. },
  907. /**
  908. * 落点定位
  909. */
  910. dropLocation(lat, lng) {
  911. this.viewer.camera.flyTo({
  912. destination: Cesium.Cartesian3.fromDegrees(lng, lat, 3000),
  913. });
  914. },
  915. /**
  916. * 地图画线(贴地)
  917. */
  918. setConnectList(connectList, color, withAlpha) {
  919. let that = this
  920. //Cesium.Color.fromCssColorString('#67ADDF') 16进制颜色设置
  921. let material = Cesium.Color.fromCssColorString(color).withAlpha(withAlpha);
  922. that.connectBoxEntity = that.viewer.entities.add({
  923. Type: 'Polyline',
  924. polyline: {
  925. positions: Cesium.Cartesian3.fromDegreesArray(connectList),
  926. clampToGround: true, //贴地 true,不贴地 false
  927. width: 5,
  928. material: material
  929. }
  930. })
  931. },
  932. /**
  933. * 地图图形(贴地)
  934. */
  935. setGraphicsList(graphicsList, color, withAlpha) {
  936. let that = this
  937. //Cesium.Color.fromCssColorString('#67ADDF') 16进制颜色设置
  938. let material = Cesium.Color.fromCssColorString(color).withAlpha(withAlpha);
  939. that.graphicsBoxEntity = that.viewer.entities.add({
  940. polygon: {
  941. hierarchy: Cesium.Cartesian3.fromDegreesArray(graphicsList),
  942. clampToGround: true, //贴地 true,不贴地 false
  943. width: 5,
  944. material: material
  945. }
  946. })
  947. }
  948. },
  949. }
  950. </script>
  951. <style rel="stylesheet/scss" lang="scss" scoped>
  952. .map-tit {
  953. position: absolute;
  954. top: 90px;
  955. left: 50%;
  956. transform: translatex(-50%);
  957. border: 1px solid #15519b;
  958. z-index: 9999;
  959. background: linear-gradient(rgba(4, 23, 62, 0.6), rgba(0, 28, 70, 0.6));
  960. min-width: 300px;
  961. .top-tit {
  962. width: 100%;
  963. height: 28px;
  964. line-height: 28px;
  965. display: flex;
  966. flex-direction: row;
  967. justify-content: space-between;
  968. background: #15519b80;
  969. padding: 0px 10px;
  970. align-items: center;
  971. i {
  972. color: #10ccff;
  973. font-size: 18px;
  974. text-shadow: 0px 0px 5px #23b3b3;
  975. ;
  976. }
  977. span img {
  978. display: block;
  979. width: 12px;
  980. height: 12px;
  981. color: #fff;
  982. cursor: pointer;
  983. }
  984. }
  985. .map-txt {
  986. padding: 10px 15px;
  987. color: #fff;
  988. line-height: 20px;
  989. font-size: 12px;
  990. .d-l-con {}
  991. }
  992. }
  993. .fade-enter-active,
  994. .fade-leave-active {
  995. transition: 1s;
  996. }
  997. .fade-enter,
  998. .fade-leave-to {
  999. opacity: 0;
  1000. transform: translateY(-10rem);
  1001. }
  1002. .map-tit{
  1003. .sj-icon-btn{
  1004. display: block;
  1005. margin: 10px auto 15px auto;
  1006. padding: 0px 16px;
  1007. font-size: 10px;
  1008. height: 1.7rem;
  1009. }
  1010. }
  1011. </style>