supermap-2.5d.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032
  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: [], //地图面实体
  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. ;
  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. mapShow() {
  299. this.mapshow = false,
  300. clearInterval(this.timer)
  301. },
  302. //清除所有
  303. clearAll() {
  304. this.viewer.entities.removeAll()
  305. },
  306. //移除之前添加的点
  307. clearM() {
  308. if (this.markerboxEntity != null && this.markerboxEntity.length > 0) {
  309. for (let i = 0; i < this.markerboxEntity.length; i++) {
  310. this.viewer.entities.remove(this.markerboxEntity[i])
  311. }
  312. this.markerboxEntity = []
  313. }
  314. },
  315. //移除之前添加的点
  316. clearMRadius() {
  317. if (this.markerboxEntityRadius != null && this.markerboxEntityRadius.length > 0) {
  318. for (let i = 0; i < this.markerboxEntityRadius.length; i++) {
  319. this.viewer.entities.remove(this.markerboxEntityRadius[i])
  320. }
  321. this.markerboxEntityRadius = []
  322. }
  323. },
  324. //移除之前添加的线
  325. clearC() {
  326. if (this.connectBoxEntity != null) {
  327. this.viewer.entities.remove(this.connectBoxEntity)
  328. this.connectBoxEntity = null
  329. }
  330. },
  331. //移除之前添加的线
  332. clearTwoC() {
  333. if (this.connectBoxEntityTwo != null) {
  334. this.viewer.entities.remove(this.connectBoxEntityTwo)
  335. this.connectBoxEntityTwo = null
  336. }
  337. },
  338. //移除之前添加的面
  339. clearG() {
  340. if (this.graphicsBoxEntity != null && this.graphicsBoxEntity.length > 0) {
  341. for (let i = 0; i < this.graphicsBoxEntity.length; i++) {
  342. this.viewer.entities.remove(this.graphicsBoxEntity[i])
  343. }
  344. this.graphicsBoxEntity = []
  345. }
  346. },
  347. superMapInfo(index) {
  348. getConfigKey('superMap.iServer').then(response => {
  349. this.superMapRootUrl = response.msg;
  350. this.onload(index);
  351. })
  352. },
  353. onload(index) {
  354. let that = this;
  355. const withinData = this.supermapUrls[index];
  356. //1.添加地形数据
  357. that.viewer = new Cesium.Viewer('cesiumContainer', {
  358. //创建地形服务提供者的实例,url为SuperMap iServer发布的TIN地形服务
  359. terrainProvider: new Cesium.CesiumTerrainProvider({
  360. url: that.superMapRootUrl + "/3D-sipingchangjing/rest/realspace/datas/dem@spyx4326",
  361. //isSct : false,//地形服务源自SuperMap iServer发布时需设置isSct为true
  362. invisibility: true
  363. }),
  364. infoBox: false,
  365. navigation: false
  366. }, {
  367. contextOptions: {
  368. msaaLevel: 4,
  369. requestWebgl2: true
  370. },
  371. orderIndependentTranslucency: false
  372. });
  373. that.scene = that.viewer.scene;
  374. that.viewer.cesiumWidget.creditContainer.style.display = "none" // 去掉超图logo水印
  375. //2.添加SuperMap iServer发布的影像服务
  376. let layer = that.viewer.imageryLayers.addImageryProvider(new Cesium.SuperMapImageryProvider({
  377. url: that.superMapRootUrl + withinData[0],
  378. }));
  379. if (index == 0) { //全部
  380. //飞行值坐标点,每3秒推进一级
  381. //heading-代表镜头左右方向,正值为右,负值为左
  382. //pitch-代表镜头上下方向,正值为上,负值为下.
  383. //roll-代表镜头左右倾斜,正值,向右倾斜,负值向左倾斜
  384. setTimeout(function () {
  385. that.viewer.camera.flyTo({
  386. destination: Cesium.Cartesian3.fromDegrees(124.49980650138238, 43.428263986216815, 950000),
  387. orientation: {
  388. // heading : Cesium.Math.toRadians(346.4202942851978),
  389. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  390. // roll : Cesium.Math.toRadians(0)
  391. }
  392. });
  393. }, 3000);
  394. setTimeout(function () {
  395. that.viewer.camera.flyTo({
  396. destination: Cesium.Cartesian3.fromDegrees(124.49980650138238, 43.428263986216815, 650000),
  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, 350000),
  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. } else if (index == 1) { //双辽
  415. //飞行值坐标点,每3秒推进一级
  416. //heading-代表镜头左右方向,正值为右,负值为左
  417. //pitch-代表镜头上下方向,正值为上,负值为下.
  418. //roll-代表镜头左右倾斜,正值,向右倾斜,负值向左倾斜
  419. setTimeout(function () {
  420. that.viewer.camera.flyTo({
  421. destination: Cesium.Cartesian3.fromDegrees(123.77896424451833, 43.70521317451045, 950000),
  422. orientation: {
  423. // heading : Cesium.Math.toRadians(346.4202942851978),
  424. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  425. // roll : Cesium.Math.toRadians(0)
  426. }
  427. });
  428. }, 3000);
  429. setTimeout(function () {
  430. that.viewer.camera.flyTo({
  431. destination: Cesium.Cartesian3.fromDegrees(123.77896424451833, 43.70521317451045, 650000),
  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, 200000),
  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. } else if (index == 2) { //梨树
  450. //飞行值坐标点,每3秒推进一级
  451. //heading-代表镜头左右方向,正值为右,负值为左
  452. //pitch-代表镜头上下方向,正值为上,负值为下.
  453. //roll-代表镜头左右倾斜,正值,向右倾斜,负值向左倾斜
  454. setTimeout(function () {
  455. that.viewer.camera.flyTo({
  456. destination: Cesium.Cartesian3.fromDegrees(124.28276991763133, 43.46361757293432, 950000),
  457. orientation: {
  458. // heading : Cesium.Math.toRadians(346.4202942851978),
  459. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  460. // roll : Cesium.Math.toRadians(0)
  461. }
  462. });
  463. }, 3000);
  464. setTimeout(function () {
  465. that.viewer.camera.flyTo({
  466. destination: Cesium.Cartesian3.fromDegrees(124.28276991763133, 43.46361757293432, 650000),
  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, 200000),
  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. } else if (index == 3) { //铁西
  485. //飞行值坐标点,每3秒推进一级
  486. //heading-代表镜头左右方向,正值为右,负值为左
  487. //pitch-代表镜头上下方向,正值为上,负值为下.
  488. //roll-代表镜头左右倾斜,正值,向右倾斜,负值向左倾斜
  489. setTimeout(function () {
  490. that.viewer.camera.flyTo({
  491. destination: Cesium.Cartesian3.fromDegrees(124.35516104252032, 43.220384847557234, 1050000),
  492. orientation: {
  493. // heading : Cesium.Math.toRadians(346.4202942851978),
  494. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  495. // roll : Cesium.Math.toRadians(0)
  496. }
  497. });
  498. }, 3000);
  499. setTimeout(function () {
  500. that.viewer.camera.flyTo({
  501. destination: Cesium.Cartesian3.fromDegrees(124.35516104252032, 43.220384847557234, 550000),
  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, 50000),
  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. } else if (index == 4) { //铁东
  520. //飞行值坐标点,每3秒推进一级
  521. //heading-代表镜头左右方向,正值为右,负值为左
  522. //pitch-代表镜头上下方向,正值为上,负值为下.
  523. //roll-代表镜头左右倾斜,正值,向右倾斜,负值向左倾斜
  524. setTimeout(function () {
  525. that.viewer.camera.flyTo({
  526. destination: Cesium.Cartesian3.fromDegrees(124.54435750508439, 43.04539078139383, 950000),
  527. orientation: {
  528. // heading : Cesium.Math.toRadians(346.4202942851978),
  529. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  530. // roll : Cesium.Math.toRadians(0)
  531. }
  532. });
  533. }, 3000);
  534. setTimeout(function () {
  535. that.viewer.camera.flyTo({
  536. destination: Cesium.Cartesian3.fromDegrees(124.54435750508439, 43.04539078139383, 650000),
  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, 100000),
  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. } else if (index == 5) { //伊通
  555. //飞行值坐标点,每3秒推进一级
  556. //heading-代表镜头左右方向,正值为右,负值为左
  557. //pitch-代表镜头上下方向,正值为上,负值为下.
  558. //roll-代表镜头左右倾斜,正值,向右倾斜,负值向左倾斜
  559. setTimeout(function () {
  560. that.viewer.camera.flyTo({
  561. destination: Cesium.Cartesian3.fromDegrees(125.34420717245336, 43.35653920782364, 950000),
  562. orientation: {
  563. // heading : Cesium.Math.toRadians(346.4202942851978),
  564. // pitch : Cesium.Math.toRadians(-56.74026687972041),
  565. // roll : Cesium.Math.toRadians(0)
  566. }
  567. });
  568. }, 3000);
  569. setTimeout(function () {
  570. that.viewer.camera.flyTo({
  571. destination: Cesium.Cartesian3.fromDegrees(125.34420717245336, 43.35653920782364, 650000),
  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, 150000),
  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. }
  590. //开始加载专题图等数据,8秒后开始执行
  591. setTimeout(function () {
  592. // 3.水系
  593. // let shuixi = that.superMapRootUrl+"/map-mvt-shuixiMian/restjsr/v1/vectortile/maps/shuixi_Mian";
  594. // that.mvtMap0 = that.scene.addVectorTilesMap({
  595. // url: shuixi,
  596. // canvasWidth: 512,
  597. // name: 'mvt_map0',
  598. // viewer: that.viewer,
  599. // selectedColor:new Cesium.Color(6,169,254,0.5),
  600. // show:true,
  601. // });
  602. // //4.林地
  603. // let lindi = that.superMapRootUrl+"/map-mvt-lindi/restjsr/v1/vectortile/maps/lindi";
  604. // that.mvtMap1 = that.scene.addVectorTilesMap({
  605. // url: lindi,
  606. // canvasWidth: 512,
  607. // name: 'mvt_map1',
  608. // viewer: that.viewer,
  609. // selectedColor:new Cesium.Color(6,254,181,0.5),
  610. // show:true,
  611. // });
  612. //
  613. //5.农田
  614. // if(that.showLayer){
  615. // let nongtian = that.superMapRootUrl + withinData[4];
  616. // that.mvtMap2 = that.scene.addVectorTilesMap({
  617. // url: nongtian,
  618. // canvasWidth: 512,
  619. // name: 'mvt_map2',
  620. // viewer: that.viewer,
  621. // selectedColor: new Cesium.Color(250, 236, 246, 1.0),
  622. // show: true,
  623. // });
  624. // }
  625. //
  626. // //6.路网
  627. // let road = that.superMapRootUrl+"/map-mvt-roadXian/restjsr/v1/vectortile/maps/road_Xian";
  628. // that.mvtMap3 = that.scene.addVectorTilesMap({
  629. // url: road,
  630. // canvasWidth: 512,
  631. // name: 'mvt_map3',
  632. // viewer: that.viewer,
  633. // show:true,
  634. // });
  635. //
  636. // //7.添加路网NAME
  637. // let road_name_url = that.superMapRootUrl+'/3D-road_Name_S/rest/realspace';
  638. // that.road_name = that.scene.open(road_name_url);
  639. //
  640. // // 8.添加水系NAME
  641. // let shuixi_name_url = that.superMapRootUrl + '/3D-shuixi_Name/rest/realspace';
  642. // that.shuixi_name = that.scene.open(shuixi_name_url);
  643. //9.添加县界和乡镇界
  644. let layer_xianjie = that.viewer.imageryLayers.addImageryProvider(new Cesium.SuperMapImageryProvider({
  645. url: that.superMapRootUrl + withinData[12],
  646. }));
  647. //10.添加区县乡镇村名称
  648. let layer_xiangzhenjie_name = that.superMapRootUrl + withinData[13];
  649. that.scene.open(layer_xiangzhenjie_name);
  650. that.cacheData.XianJie = withinData[14]
  651. that.cacheData.XiangZhenJie = withinData[15]
  652. that.cacheData.Cun = withinData[16]
  653. that.road_name.then(function (layers) {
  654. let xianJie_textLayer = that.scene.layers.find(withinData[14]);//区县文字图层
  655. let xiangZhenJie_textLayer = that.scene.layers.find(withinData[15]);//乡镇文字图层
  656. let cun_textLayer = that.scene.layers.find(withinData[16]);//村文字图层
  657. //关闭避让
  658. xianJie_textLayer.isOverlapDisplayed = true;
  659. xiangZhenJie_textLayer.isOverlapDisplayed = true;
  660. cun_textLayer.isOverlapDisplayed = true;
  661. });
  662. }, 3000);
  663. that.viewer.selectedEntityChanged.addEventListener(function (entity) {
  664. if (entity != undefined && Reflect.has(entity, 'layerID')) {
  665. that.queryParams.name = entity.pickResult[entity.layerID][0].feature.properties.Name;
  666. that.queryParams.mapData = entity.pickResult[entity.layerID][0].feature.properties.SmUserID;
  667. that.queryParams.mapName = entity.pickResult[entity.layerID][0].feature.properties.layer;
  668. getDeviceList(that.queryParams).then(res => {
  669. const treeLabels = [{
  670. "id": null,
  671. "labelCode": "999",
  672. "labelName": "电视墙",
  673. "cameraType": null,
  674. "parentLabelCode": ""
  675. }];
  676. const labelChannels = [];
  677. for (let i in res.data) {
  678. treeLabels.push({
  679. "id": null,
  680. "labelCode": res.data[i].cameraCode,
  681. "labelName": res.data[i].cameraName,
  682. "cameraType": "1",
  683. "parentLabelCode": "999"
  684. })
  685. labelChannels.push({
  686. "labelCode": res.data[i].cameraCode,
  687. "channelDates": [
  688. {
  689. "channelCode": res.data[i].cameraCode,
  690. "channelName": res.data[i].cameraName,
  691. "channelSn": null,
  692. "cameraType": "1",
  693. "online": "1",
  694. "cameraCode": "1"
  695. }
  696. ]
  697. })
  698. }
  699. const dianshiqiang = [
  700. {
  701. "switchTab": "2",
  702. "treeLabels": treeLabels,
  703. "labelChannels": labelChannels
  704. }
  705. ]
  706. that.$emit('fatherMethod', dianshiqiang, res.data[0].longitude, res.data[0].latitude, res.data[0].userList);
  707. });
  708. }
  709. });
  710. },
  711. /**
  712. * 地图落点
  713. */
  714. setMarkers(makerList) {
  715. let that = this
  716. that.handler = new Cesium.ScreenSpaceEventHandler(that.viewer.scene.canvas)
  717. clearInterval(that.aac)
  718. for (let i in makerList) {
  719. let longitude = makerList[i].lng
  720. let latitude = makerList[i].lat
  721. let marker = that.viewer.entities.add({
  722. name: '',
  723. position: Cesium.Cartesian3.fromDegrees(longitude, latitude),
  724. billboard: {
  725. image: iconList[makerList[i].icon],
  726. width: 48,
  727. height: 48,
  728. heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
  729. disableDepthTestDistance: Number.POSITIVE_INFINITY
  730. },
  731. description: makerList[i].bindPopupHtml,
  732. click: makerList[i].click,
  733. parameter: makerList[i].parameter
  734. })
  735. that.markerboxEntity.push(marker)
  736. }
  737. that.viewer.scene.globe.depthTestAgainstTerrain = false
  738. that.createLeftClickDescription()
  739. that.createRightClickDescription()
  740. },
  741. /**
  742. *鼠标左击事件是原来的气泡
  743. */
  744. createLeftClickDescription() {
  745. let that = this;
  746. that.handler.setInputAction(function (movement) {
  747. that.pick = that.viewer.scene.pick(movement.position);
  748. if (that.pick && that.pick) {
  749. let id = Cesium.defaultValue(that.viewer.scene.pick(movement.position).id, that.viewer.scene.pick(
  750. movement.position).primitive.id);
  751. let html = id._description;
  752. clearInterval(that.timer)
  753. if (html != undefined && html._value != null && html._value != '' && html != 'cgq') {
  754. that.bindPopupHtml = html
  755. that.mapshow = true
  756. } else if (html == 'cgq') {
  757. that.timer = setInterval(function () {
  758. var color = "green";
  759. var value = Math.random();
  760. var up = "▲";
  761. var down = "▼";
  762. if (value > 0.5) {
  763. color = "red";
  764. value = value + "" + up;
  765. } else {
  766. value = value + "" + down;
  767. }
  768. that.bindPopupHtml = "<span style='color:" + color + "'>当前传感器数值: " + value + "</span>";
  769. }, 1000)
  770. that.mapshow = true
  771. } else {
  772. that.mapshow = false
  773. clearInterval(that.timer)
  774. }
  775. } else {
  776. that.mapshow = false
  777. clearInterval(that.timer)
  778. }
  779. }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
  780. },
  781. /**
  782. *鼠标右击事件是原来的点击
  783. */
  784. createRightClickDescription() {
  785. let that = this;
  786. that.handler.setInputAction(function (movement) {
  787. that.mapshow = false
  788. if (new Date().getTime() - that.clickTime < 2000) {
  789. return
  790. } else {
  791. that.clickTime = new Date().getTime()
  792. }
  793. clearInterval(that.timer)
  794. // 监听鼠标的当前位置坐标,然后根据当前坐标去动态更新气泡窗口div的显示位置;
  795. that.pick = that.viewer.scene.pick(movement.position);
  796. if (that.pick && that.pick) {
  797. let id = Cesium.defaultValue(that.viewer.scene.pick(movement.position).id, that.viewer.scene.pick(
  798. movement.position).primitive.id);
  799. let clickName = id._click;
  800. that.$emit(clickName, id._parameter)
  801. }
  802. }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
  803. },
  804. /**
  805. * 落点定位
  806. */
  807. dropLocation(lat, lng) {
  808. this.viewer.camera.flyTo({
  809. destination: Cesium.Cartesian3.fromDegrees(lng, lat, 3000),
  810. });
  811. },
  812. /**
  813. * 地图画线(贴地)
  814. */
  815. setConnectList(connectList, color, withAlpha) {
  816. let that = this
  817. //Cesium.Color.fromCssColorString('#67ADDF') 16进制颜色设置
  818. let material = Cesium.Color.fromCssColorString(color).withAlpha(withAlpha);
  819. that.connectBoxEntity = that.viewer.entities.add({
  820. Type: 'Polyline',
  821. polyline: {
  822. positions: Cesium.Cartesian3.fromDegreesArray(connectList),
  823. clampToGround: true, //贴地 true,不贴地 false
  824. width: 5,
  825. material: material
  826. }
  827. })
  828. },
  829. /**
  830. * 地图落点-覆盖范围
  831. */
  832. setMarkersRadius(makerList) {
  833. let that = this
  834. that.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)
  835. for (let i in makerList) {
  836. let longitude = makerList[i].lng;
  837. let latitude = makerList[i].lat;
  838. let marker = that.viewer.entities.add({
  839. name: "",
  840. position: Cesium.Cartesian3.fromDegrees(longitude, latitude),
  841. billboard: {
  842. image: iconList[makerList[i].icon],
  843. width: 48,
  844. height: 48,
  845. heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
  846. disableDepthTestDistance: Number.POSITIVE_INFINITY
  847. },
  848. description: makerList[i].bindPopupHtml,
  849. click: makerList[i].click,
  850. parameter: makerList[i].parameter
  851. })
  852. that.markerboxEntityRadius.push(marker)
  853. //绘制摄像头的圈(覆盖范围)
  854. let markerRadius = that.viewer.entities.add({
  855. position: Cesium.Cartesian3.fromDegrees(makerList[i].lng, makerList[i].lat, 2),
  856. ellipse: {
  857. semiMinorAxis: makerList[i].radius,
  858. semiMajorAxis: makerList[i].radius,
  859. height: 0.0,
  860. material: Cesium.Color.DODGERBLUE.withAlpha(0.4),
  861. outline: true,
  862. outlineColor: Cesium.Color.DEEPSKYBLUE.withAlpha(1),
  863. outlineWidth: 1,
  864. },
  865. });
  866. that.markerboxEntityRadius.push(markerRadius)
  867. }
  868. that.viewer.scene.globe.depthTestAgainstTerrain = false
  869. that.createLeftClickDescription()
  870. that.createRightClickDescription()
  871. },
  872. /**
  873. * 地图画线(贴地)
  874. */
  875. setConnectTwoList(connectList, color, withAlpha) {
  876. let that = this
  877. //Cesium.Color.fromCssColorString('#67ADDF') 16进制颜色设置
  878. let material = Cesium.Color.fromCssColorString(color).withAlpha(withAlpha);
  879. that.connectBoxEntityTwo = that.viewer.entities.add({
  880. Type: 'Polyline',
  881. polyline: {
  882. positions: Cesium.Cartesian3.fromDegreesArray(connectList),
  883. clampToGround: true, //贴地 true,不贴地 false
  884. width: 5,
  885. material: material
  886. }
  887. })
  888. },
  889. /**
  890. * 地图图形(贴地)
  891. */
  892. setGraphicsList(graphicsList, color, withAlpha) {
  893. let that = this
  894. //Cesium.Color.fromCssColorString('#67ADDF') 16进制颜色设置
  895. let material = Cesium.Color.fromCssColorString(color).withAlpha(withAlpha);
  896. let graphicsBoxEntity = that.viewer.entities.add({
  897. polygon: {
  898. hierarchy: Cesium.Cartesian3.fromDegreesArray(graphicsList),
  899. clampToGround: true, //贴地 true,不贴地 false
  900. width: 5,
  901. material: material
  902. }
  903. })
  904. that.graphicsBoxEntity.push(graphicsBoxEntity);
  905. },
  906. /**
  907. * 地图图形(贴地)
  908. */
  909. setGraphicsListMultiple(graphicsList, color, withAlpha) {
  910. let that = this
  911. //Cesium.Color.fromCssColorString('#67ADDF') 16进制颜色设置
  912. let material = Cesium.Color.fromCssColorString(color).withAlpha(withAlpha);
  913. for (let i = 0; i < graphicsList.length; i++) {
  914. if (graphicsList[i].latLngs != null && graphicsList[i].latLngs != "") {
  915. let jsonToArr = JSON.parse(graphicsList[i].latLngs);
  916. const arr = []
  917. for (let j = 0; j < jsonToArr.length; j++) {
  918. arr.push(jsonToArr[j].lng)
  919. arr.push(jsonToArr[j].lat)
  920. }
  921. let graphicsBoxEntity = that.viewer.entities.add({
  922. polygon: {
  923. hierarchy: Cesium.Cartesian3.fromDegreesArray(arr),
  924. clampToGround: true, //贴地 true,不贴地 false
  925. width: 5,
  926. material: material
  927. }
  928. })
  929. that.graphicsBoxEntity.push(graphicsBoxEntity);
  930. }
  931. }
  932. }
  933. },
  934. }
  935. </script>
  936. <style rel="stylesheet/scss" lang="scss" scoped>
  937. .map-tit {
  938. position: absolute;
  939. top: 90px;
  940. left: 50%;
  941. transform: translatex(-50%);
  942. border: 1px solid #15519b;
  943. z-index: 9999;
  944. background: linear-gradient(rgba(4, 23, 62, 0.6), rgba(0, 28, 70, 0.6));
  945. min-width: 300px;
  946. .top-tit {
  947. width: 100%;
  948. height: 28px;
  949. line-height: 28px;
  950. display: flex;
  951. flex-direction: row;
  952. justify-content: space-between;
  953. background: #15519b80;
  954. padding: 0px 10px;
  955. align-items: center;
  956. i {
  957. color: #10ccff;
  958. font-size: 18px;
  959. text-shadow: 0px 0px 5px #23b3b3;;
  960. }
  961. span img {
  962. display: block;
  963. width: 12px;
  964. height: 12px;
  965. color: #fff;
  966. cursor: pointer;
  967. }
  968. }
  969. .map-txt {
  970. padding: 10px 15px;
  971. color: #fff;
  972. line-height: 20px;
  973. font-size: 12px;
  974. .d-l-con {
  975. }
  976. }
  977. }
  978. .fade-enter-active,
  979. .fade-leave-active {
  980. transition: 1s;
  981. }
  982. .fade-enter,
  983. .fade-leave-to {
  984. opacity: 0;
  985. transform: translateY(-10rem);
  986. }
  987. </style>