location-region.vue 9.1 KB

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