supermap-2.5d.vue 39 KB

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