supermap-2.5d.vue 41 KB

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