supermap-2.5d.vue 37 KB

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