supermap-2.5d.vue 39 KB

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