mapNavigate.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. <script setup>
  2. import {
  3. ref
  4. } from 'vue';
  5. import {
  6. inject
  7. } from "vue";
  8. import selshi from '@/assets/images/selshi.png';
  9. import selcun from '@/assets/images/selcun.png';
  10. import cun from '@/assets/images/cun.png';
  11. import shi from '@/assets/images/shi.png';
  12. import xian from '@/assets/images/xian.png';
  13. import selxian from '@/assets/images/selxian.png';
  14. const getMapInstance = inject("getMapInstance");
  15. jt3d = getMapInstance();
  16. </script>
  17. <template>
  18. <div class="tabs">
  19. <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
  20. <i v-for="(item,index) in cityList">
  21. <el-tab-pane :name="item.number">
  22. <template #label>
  23. <span class="custom-tabs-label">
  24. <img v-if="index==0" :src="isindex==0?selshi:shi">
  25. <img v-if="index==1" :src="isindex==1?selxian:xian">
  26. <img v-if="index==2" :src="isindex==2?selcun:cun">
  27. <span>{{item.label}}</span>
  28. </span>
  29. </template>
  30. <template #default>
  31. <div class="content">
  32. <div :class="dj == 1?'item':'item2'" v-for="(res,num) in ALLlist" @click="selectCity(res.label,index+1,res.regioncode,res.dj)">
  33. <div :class="addcolor(num)" @click="currentidx(num)">
  34. <span>{{res.label}}</span>
  35. </div>
  36. </div>
  37. </div>
  38. </template>
  39. </el-tab-pane>
  40. </i>
  41. </el-tabs>
  42. </div>
  43. <div class="Ficons">
  44. <!-- <span>遮罩</span> -->
  45. <!-- <el-icon color="#ffffff" class="icons" @click="hide" :size="20">
  46. <View v-show="!hideicon" />
  47. <Hide v-show="hideicon" />
  48. </el-icon> -->
  49. </div>
  50. </template>
  51. <script>
  52. let jt3d = undefined;
  53. let entities = undefined;
  54. export default {
  55. data() {
  56. return {
  57. currentIndex: -1,
  58. isindex: 0, //判断选中第几个标题
  59. cityList: [{
  60. label: '牟平',
  61. number: 0,
  62. dj: 1
  63. }], //tab数组展示列表
  64. activeName: 0, //选中的下标牵引
  65. ALLlist: [], //所有子集城市
  66. downlist: [], //村集
  67. dj: 1, //控制列表样式
  68. entities: undefined,
  69. hideicon: false, //控制遮罩层显示
  70. acolor: true, //是否展示颜色
  71. }
  72. },
  73. watch: {
  74. //改变高度值
  75. activeName() {
  76. this.acolor = false
  77. }
  78. },
  79. methods: {
  80. currentidx(index) {
  81. this.currentIndex = index
  82. this.acolor = true
  83. },
  84. //添加颜色样式
  85. addcolor(index) {
  86. if (this.currentIndex == index) {
  87. return {
  88. active: this.acolor
  89. }
  90. }
  91. },
  92. /**
  93. *控制遮罩层
  94. */
  95. hide() {
  96. this.hideicon = !this.hideicon
  97. if (this.hideicon) {
  98. entities[0].polygon.material = Cesium.Color.fromBytes(50, 160, 255, 1)
  99. } else {
  100. entities[0].polygon.material = Cesium.Color.fromBytes(50, 160, 255, 77)
  101. }
  102. },
  103. /**
  104. * 移除定位样式
  105. */
  106. remove() {
  107. if (window["viewer"].dataSources.getByName('标绘区')) {
  108. window["viewer"].dataSources.remove(window["viewer"].dataSources.getByName('标绘区')[0])
  109. }
  110. },
  111. //头部标题点击事件
  112. handleClick(data) {
  113. let index = Number(data.index)
  114. //判断点击的是否是第一个标题
  115. if (index == 0) {
  116. this.getcityList()
  117. this.cityList = this.cityList.slice(0, index + 1)
  118. this.isindex = index
  119. this.activeName = index
  120. //全图事件
  121. this.$parent.$parent.$refs.refMap3d.fullMap(jt3d);
  122. }
  123. },
  124. /*
  125. *** label 城镇村庄名字
  126. * * index 选中下标
  127. * * regioncode 编号
  128. * * dj 村镇等级
  129. */
  130. selectCity(label, index, regioncode, dj) {
  131. let _this = this
  132. if (!regioncode) {
  133. return
  134. }
  135. //如果等级为1,代表点击的乡镇,需要重新设置ALLlist为村庄列表,并在头部添加乡镇名称
  136. if (dj == 1) {
  137. this.cityList.push({
  138. label: label,
  139. number: index,
  140. dj: 2
  141. })
  142. var id = regioncode.slice(0, 9)
  143. this.isindex = index
  144. this.activeName = index
  145. this.$http.get('/getTableList', {
  146. tableName: 'map_region', //
  147. sqlWhere: "dj = 2 and regioncode like '" + id + "%'",
  148. orderByField: ''
  149. }).then(res => {
  150. if(res.data.length == 0) return
  151. this.dj = 2
  152. this.ALLlist = []
  153. res.data.forEach(
  154. item => {
  155. this.ALLlist.push({
  156. label: item.regionname,
  157. regioncode: item.regioncode,
  158. dj: item.dj
  159. })
  160. }
  161. )
  162. })
  163. }
  164. //根据等级与id获取乡镇或者村庄的面坐标
  165. this.$http.get('/getGeoJson', {
  166. tableName: 'map_region', //
  167. sqlWhere: "dj = " + dj + " and regioncode like '" + regioncode + "%'",
  168. orderByField: ''
  169. }).then(res => {
  170. if (window["viewer"].dataSources.getByName('标绘区')) {
  171. window["viewer"].dataSources.remove(window["viewer"].dataSources.getByName('标绘区')[0])
  172. }
  173. let promise = Cesium.GeoJsonDataSource.load(res.data, {
  174. clampToGround: true
  175. });
  176. promise.then((dataSource) => {
  177. window["viewer"].dataSources.add(dataSource); // 加载这个geojson资源
  178. dataSource.name = '标绘区'
  179. entities = dataSource.entities.values;
  180. const entity = entities[0];
  181. entity.polygon.material = Cesium.Color.fromBytes(50, 160, 255, 77)
  182. entity.polygon.outlineWidth = 3;
  183. entity.polygon.outline = false;
  184. entity.polygon.outlineColor = Cesium.Color.RED;
  185. entity.polyline = {
  186. positions: entity.polygon.hierarchy._value.positions,
  187. width: entity.polygon.outlineWidth,
  188. material: Cesium.Color.fromBytes(0, 255, 180, 255),
  189. clampToGround: true
  190. }
  191. _this.hideicon = false;
  192. let options = {};
  193. // 初始化参数默认值
  194. options.duration = Cesium.defaultValue(options.duration, 2);
  195. options.heading = Cesium.defaultValue(options.heading, 0);
  196. options.pitch = Cesium.defaultValue(options.pitch, -60);
  197. options.range = Cesium.defaultValue(options.range, 0.0);
  198. let colorList = [
  199. [90, 120, 255, 153],
  200. [150, 255, 90, 153],
  201. [255, 150, 50, 153],
  202. [50, 160, 255, 77]
  203. ]
  204. let flyPromise = window["viewer"].flyTo(entities, {
  205. duration: options.duration,
  206. offset: {
  207. heading: Cesium.Math.toRadians(options.heading),
  208. pitch: Cesium.Math.toRadians(options.pitch),
  209. range: options.range
  210. }
  211. });
  212. flyPromise.then(res => {
  213. let isremove = true
  214. //面首次加载颜色
  215. const entity = entities[0];
  216. entity.polygon.material = Cesium.Color.fromBytes(colorList[0][0],
  217. colorList[0][1], colorList[0][2], colorList[0][3])
  218. let idx = 1
  219. let timer = setInterval(res => {
  220. const entity = entities[0];
  221. entity.polygon.material = Cesium.Color.fromBytes(
  222. colorList[idx][0], colorList[idx][1],
  223. colorList[idx][2], colorList[idx][3])
  224. idx++
  225. }, 500)
  226. setTimeout(res => {
  227. clearInterval(timer)
  228. _this.hide();
  229. }, 2100)
  230. })
  231. });
  232. })
  233. },
  234. getcityList() {
  235. this.dj = 1
  236. this.ALLlist = []
  237. this.$http.get('/getTableList', {
  238. tableName: 'map_region',
  239. sqlWhere: 'dj = 1',
  240. orderByField: ''
  241. }).then(res => {
  242. if(res.data.length == 0) return
  243. res.data.forEach(
  244. item => {
  245. console.log('城镇信息', item)
  246. this.ALLlist.push({
  247. label: item.regionname,
  248. regioncode: item.regioncode,
  249. dj: item.dj
  250. })
  251. }
  252. )
  253. })
  254. }
  255. },
  256. mounted() {
  257. this.getcityList()
  258. }
  259. }
  260. </script>
  261. <style lang="scss" scoped>
  262. .Ficons {
  263. position: absolute;
  264. top: 10rem;
  265. left: 20rem;
  266. }
  267. .active {
  268. color: #409eff;
  269. }
  270. //整体样式
  271. .tabs {
  272. width: 90%;
  273. margin-left: 5%;
  274. text-align: left;
  275. --el-font-size-base: 16rem;
  276. .item {
  277. // width: 135rem;
  278. width: 80rem;
  279. display: inline-block;
  280. height: 42rem;
  281. margin-right: 15rem;
  282. color: #ffffff;
  283. font-size: 16rem;
  284. cursor: pointer;
  285. white-space: nowrap;
  286. /*显示的行数;如果要设置2行加...则设置为2*/
  287. overflow: hidden;
  288. /*超出的文本隐藏*/
  289. text-overflow: ellipsis;
  290. /* 溢出用省略号*/
  291. font-style: normal;
  292. }
  293. .item2 {
  294. width: 65rem;
  295. display: inline-block;
  296. height: 35rem;
  297. margin-right: 10rem;
  298. color: #ffffff;
  299. font-size: 16rem;
  300. cursor: pointer;
  301. white-space: nowrap;
  302. /*显示的行数;如果要设置2行加...则设置为2*/
  303. overflow: hidden;
  304. /*超出的文本隐藏*/
  305. text-overflow: ellipsis;
  306. /* 溢出用省略号*/
  307. font-style: normal;
  308. }
  309. .content {
  310. width: 100%;
  311. margin: 10rem 0;
  312. overflow-y: auto;
  313. }
  314. img {
  315. width: 18rem;
  316. height: 18rem;
  317. vertical-align: -10%;
  318. margin-right: 2rem;
  319. }
  320. }
  321. .demo-tabs>.el-tabs__content {
  322. padding: 32rem;
  323. color: #6b778c;
  324. font-size: 32rem;
  325. font-weight: 600;
  326. }
  327. //未选择tabs标题样式
  328. ::v-deep .el-tabs__item {
  329. color: #ffffff !important;
  330. }
  331. //选中tabs标签样式
  332. ::v-deep .el-tabs__item.is-active {
  333. color: var(--el-color-primary) !important;
  334. }
  335. //选中下划线样式
  336. ::v-deep .el-tabs__active-bar {
  337. bottom: -1rem !important;
  338. height: 4rem !important;
  339. }
  340. //下横线样式
  341. ::v-deep .el-tabs__nav-wrap::after {
  342. height: 1rem !important;
  343. background-color: darkgrey;
  344. }
  345. </style>