supermap-2.5d.vue 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077
  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=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. }
  758. else{
  759. this.$emit(this.clickName, this.parameter);
  760. }
  761. },
  762. /**
  763. * 地图落点
  764. */
  765. setMarkers(makerList) {
  766. let that = this
  767. that.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)
  768. clearInterval(that.aac)
  769. for (let i in makerList) {
  770. let longitude = makerList[i].lng
  771. let latitude = makerList[i].lat
  772. let marker = that.viewer.entities.add({
  773. name: '',
  774. position: Cesium.Cartesian3.fromDegrees(longitude, latitude),
  775. billboard: {
  776. image: iconList[makerList[i].icon],
  777. width: 48,
  778. height: 48,
  779. heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
  780. disableDepthTestDistance: Number.POSITIVE_INFINITY
  781. },
  782. description: makerList[i].bindPopupHtml,
  783. click: makerList[i].click,
  784. parameter: makerList[i].parameter
  785. })
  786. that.markerboxEntity.push(marker)
  787. }
  788. that.viewer.scene.globe.depthTestAgainstTerrain = false
  789. that.createLeftClickDescription()
  790. that.createRightClickDescription()
  791. },
  792. /**
  793. *鼠标左击事件是原来的气泡
  794. */
  795. createLeftClickDescription() {
  796. let that = this;
  797. that.handler.setInputAction(function(movement) {
  798. that.pick = that.viewer.scene.pick(movement.position);
  799. if (that.pick && that.pick) {
  800. let id = Cesium.defaultValue(that.viewer.scene.pick(movement.position).id, that.viewer.scene.pick(
  801. movement.position).primitive.id);
  802. let html = id._description;
  803. clearInterval(that.timer)
  804. if (html != undefined && html._value != null && html._value != '' && html != 'cgq') {
  805. that.bindPopupHtml = html;
  806. that.clickName=id._click;
  807. that.parameter=id._parameter;
  808. that.mapshow = true
  809. that.openZt = false
  810. } else if (html == 'cgq') {
  811. that.timer = setInterval(function() {
  812. var color = "green";
  813. var value = Math.random();
  814. var up = "▲";
  815. var down = "▼";
  816. if (value > 0.5) {
  817. color = "red";
  818. value = value + "" + up;
  819. } else {
  820. value = value + "" + down;
  821. }
  822. that.bindPopupHtml = "<span style='color:" + color + "'>当前传感器数值: " + value + "</span>";
  823. }, 1000)
  824. that.mapshow = true
  825. } else {
  826. that.mapshow = false
  827. clearInterval(that.timer)
  828. }
  829. } else {
  830. that.mapshow = false
  831. clearInterval(that.timer)
  832. }
  833. }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
  834. },
  835. /**
  836. *鼠标右击事件是原来的点击
  837. */
  838. createRightClickDescription() {
  839. let that = this;
  840. that.handler.setInputAction(function(movement) {
  841. that.mapshow = false
  842. if (new Date().getTime() - that.clickTime < 2000) {
  843. return
  844. } else {
  845. that.clickTime = new Date().getTime()
  846. }
  847. clearInterval(that.timer)
  848. // 监听鼠标的当前位置坐标,然后根据当前坐标去动态更新气泡窗口div的显示位置;
  849. that.pick = that.viewer.scene.pick(movement.position);
  850. if (that.pick && that.pick) {
  851. let id = Cesium.defaultValue(that.viewer.scene.pick(movement.position).id, that.viewer.scene.pick(
  852. movement.position).primitive.id);
  853. let clickName = id._click;
  854. that.$emit(clickName, id._parameter)
  855. }
  856. }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
  857. },
  858. /**
  859. * 落点定位
  860. */
  861. dropLocation(lat, lng) {
  862. this.viewer.camera.flyTo({
  863. destination: Cesium.Cartesian3.fromDegrees(lng, lat, 3000),
  864. });
  865. },
  866. /**
  867. * 地图画线(贴地)
  868. */
  869. setConnectList(connectList, color, withAlpha) {
  870. let that = this
  871. //Cesium.Color.fromCssColorString('#67ADDF') 16进制颜色设置
  872. let material = Cesium.Color.fromCssColorString(color).withAlpha(withAlpha);
  873. that.connectBoxEntity = that.viewer.entities.add({
  874. Type: 'Polyline',
  875. polyline: {
  876. positions: Cesium.Cartesian3.fromDegreesArray(connectList),
  877. clampToGround: true, //贴地 true,不贴地 false
  878. width: 5,
  879. material: material
  880. }
  881. })
  882. },
  883. /**
  884. * 地图落点-覆盖范围
  885. */
  886. setMarkersRadius(makerList) {
  887. let that = this
  888. that.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)
  889. for (let i in makerList) {
  890. let longitude = makerList[i].lng;
  891. let latitude = makerList[i].lat;
  892. let marker = that.viewer.entities.add({
  893. name: "",
  894. position: Cesium.Cartesian3.fromDegrees(longitude, latitude),
  895. billboard: {
  896. image: iconList[makerList[i].icon],
  897. width: 48,
  898. height: 48,
  899. heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
  900. disableDepthTestDistance: Number.POSITIVE_INFINITY
  901. },
  902. description: makerList[i].bindPopupHtml,
  903. click: makerList[i].click,
  904. parameter: makerList[i].parameter
  905. })
  906. that.markerboxEntityRadius.push(marker)
  907. //绘制摄像头的圈(覆盖范围)
  908. let markerRadius = that.viewer.entities.add({
  909. position: Cesium.Cartesian3.fromDegrees(makerList[i].lng, makerList[i].lat, 2),
  910. ellipse: {
  911. semiMinorAxis: makerList[i].radius,
  912. semiMajorAxis: makerList[i].radius,
  913. height: 0.0,
  914. material: Cesium.Color.DODGERBLUE.withAlpha(0.4),
  915. outline: true,
  916. outlineColor: Cesium.Color.DEEPSKYBLUE.withAlpha(1),
  917. outlineWidth: 1,
  918. },
  919. });
  920. that.markerboxEntityRadius.push(markerRadius)
  921. }
  922. that.viewer.scene.globe.depthTestAgainstTerrain = false
  923. that.createLeftClickDescription()
  924. that.createRightClickDescription()
  925. },
  926. /**
  927. * 地图画线(贴地)
  928. */
  929. setGraphicsList(graphicsList, color, withAlpha) {
  930. let that = this
  931. //Cesium.Color.fromCssColorString('#67ADDF') 16进制颜色设置
  932. let material = Cesium.Color.fromCssColorString(color).withAlpha(withAlpha);
  933. let graphicsBoxEntity = that.viewer.entities.add({
  934. polygon: {
  935. hierarchy: Cesium.Cartesian3.fromDegreesArray(graphicsList),
  936. clampToGround: true, //贴地 true,不贴地 false
  937. width: 5,
  938. material: material
  939. }
  940. })
  941. that.graphicsBoxEntity.push(graphicsBoxEntity);
  942. },
  943. /**
  944. * 地图图形(贴地)
  945. */
  946. setGraphicsListMultiple(graphicsList, color, withAlpha) {
  947. let that = this
  948. //Cesium.Color.fromCssColorString('#67ADDF') 16进制颜色设置
  949. let material = Cesium.Color.fromCssColorString(color).withAlpha(withAlpha);
  950. for (let i = 0; i < graphicsList.length; i++) {
  951. if (graphicsList[i].latLngs != null && graphicsList[i].latLngs != "") {
  952. let jsonToArr = JSON.parse(graphicsList[i].latLngs);
  953. const arr = []
  954. for (let j = 0; j < jsonToArr.length; j++) {
  955. arr.push(jsonToArr[j].lng)
  956. arr.push(jsonToArr[j].lat)
  957. }
  958. let graphicsBoxEntity = that.viewer.entities.add({
  959. polygon: {
  960. hierarchy: Cesium.Cartesian3.fromDegreesArray(arr),
  961. clampToGround: true, //贴地 true,不贴地 false
  962. width: 5,
  963. material: material
  964. }
  965. })
  966. that.graphicsBoxEntity.push(graphicsBoxEntity);
  967. }
  968. }
  969. }
  970. },
  971. }
  972. </script>
  973. <style rel="stylesheet/scss" lang="scss" scoped>
  974. .map-tit {
  975. position: absolute;
  976. top: 90px;
  977. left: 50%;
  978. transform: translatex(-50%);
  979. border: 1px solid #15519b;
  980. z-index: 9999;
  981. background: linear-gradient(rgba(4, 23, 62, 0.6), rgba(0, 28, 70, 0.6));
  982. min-width: 300px;
  983. .top-tit {
  984. width: 100%;
  985. height: 28px;
  986. line-height: 28px;
  987. display: flex;
  988. flex-direction: row;
  989. justify-content: space-between;
  990. background: #15519b80;
  991. padding: 0px 10px;
  992. align-items: center;
  993. i {
  994. color: #10ccff;
  995. font-size: 18px;
  996. text-shadow: 0px 0px 5px #23b3b3;
  997. ;
  998. }
  999. span img {
  1000. display: block;
  1001. width: 12px;
  1002. height: 12px;
  1003. color: #fff;
  1004. cursor: pointer;
  1005. }
  1006. }
  1007. .map-txt {
  1008. padding: 10px 15px;
  1009. color: #fff;
  1010. line-height: 20px;
  1011. font-size: 12px;
  1012. .d-l-con {}
  1013. }
  1014. }
  1015. .fade-enter-active,
  1016. .fade-leave-active {
  1017. transition: 1s;
  1018. }
  1019. .fade-enter,
  1020. .fade-leave-to {
  1021. opacity: 0;
  1022. transform: translateY(-10rem);
  1023. }
  1024. .map-tit{
  1025. .sj-icon-btn{
  1026. display: block;
  1027. margin: 10px auto 15px auto;
  1028. padding: 0px 16px;
  1029. font-size: 10px;
  1030. height: 1.7rem;
  1031. }
  1032. }
  1033. </style>