PlacenameLocation.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div class="sm-panel sm-function-module-content" v-if="PlacenameLocationShow" v-drag>
  3. <div class="sm-panel-header">
  4. <span>{{ Resource.PlacenameLocation }}</span>
  5. <span class="closeBtn" @click="toggleVisibility">&times;</span>
  6. </div>
  7. <div class="flexbox">
  8. <el-input
  9. placeholder="请输入查询关键字"
  10. prefix-icon="el-icon-search"
  11. v-model="poiSearchText"
  12. size="small"
  13. >
  14. </el-input>
  15. <el-button
  16. @click="clear"
  17. type="primary"
  18. size="small"
  19. style="margin-left: 5px"
  20. >清除</el-button
  21. >
  22. </div>
  23. <div class="flexbox" style="height: 260px; width: 100%">
  24. <el-table
  25. :show-header="false"
  26. :data="tableData"
  27. height="260"
  28. border
  29. style="width: 100%"
  30. @row-click="handleRowClick"
  31. >
  32. <el-table-column prop="name" label="兴趣点" width="310">
  33. </el-table-column>
  34. <el-table-column prop="address" label="地址" width="180" v-if="false">
  35. </el-table-column>
  36. <el-table-column
  37. prop="x"
  38. label="经度"
  39. width="180"
  40. v-if="false"
  41. ></el-table-column>
  42. <el-table-column
  43. prop="y"
  44. label="纬度"
  45. width="180"
  46. v-if="false"
  47. ></el-table-column>
  48. </el-table>
  49. </div>
  50. <div>
  51. <el-pagination
  52. @size-change="handleSizeChange"
  53. @current-change="handlePageChange"
  54. :current-page="page"
  55. :page-sizes="[10, 20, 50, 100]"
  56. :page-size="size"
  57. layout="total, sizes, prev, next"
  58. :total="total"
  59. >
  60. </el-pagination>
  61. </div>
  62. </div>
  63. </template>
  64. <script>
  65. import { PoiQuery } from "@/api/map";
  66. export default {
  67. name: "PlacenameLocation",
  68. data() {
  69. return {
  70. tableData: [],
  71. poiSearchText: "",
  72. MapViewer: window.viewer,
  73. total: 100,
  74. page: 1,
  75. size: 10,
  76. billboardHeight: 10,
  77. };
  78. },
  79. created() {},
  80. mounted() {
  81. this.poiquery();
  82. },
  83. computed: {
  84. PlacenameLocationShow() {
  85. return store.state.toolBar[10];
  86. },
  87. },
  88. methods: {
  89. toggleVisibility() {
  90. store.setToolBarAction(10);
  91. this.clear();
  92. },
  93. handlePageChange(cur, a, b) {
  94. this.page = cur;
  95. this.poiquery();
  96. },
  97. handleSizeChange(cur, a, b) {
  98. this.size = cur;
  99. this.poiquery();
  100. },
  101. poiquery() {
  102. PoiQuery({
  103. name: this.poiSearchText,
  104. limit: this.size,
  105. offset: (this.page - 1) * this.size,
  106. }).then((res) => {
  107. if (res.statuscode == 200) {
  108. this.total = res.data.count;
  109. this.tableData = res.data.data;
  110. } else {
  111. this.$message.error(res.message);
  112. }
  113. });
  114. },
  115. clear() {
  116. viewer.entities.removeAll();
  117. this.poiSearchText = "";
  118. },
  119. handleRowClick(row) {
  120. row.x = parseFloat(row.x);
  121. row.y = parseFloat(row.y);
  122. this.flyTo({ destination: { x: row.x, y: row.y, z: 1000 } }, true);
  123. viewer.entities.removeAll();
  124. viewer.entities.add({
  125. position: Cesium.Cartesian3.fromDegrees(
  126. row.x,
  127. row.y,
  128. this.billboardHeight
  129. ),
  130. billboard: {
  131. image: "./static/images/location.png",
  132. width: 30,
  133. height: 40,
  134. },
  135. name: "Mapimage" + row.x + row.y,
  136. });
  137. },
  138. /**
  139. * 飞行定位
  140. * @param {{destination:object,orientation:object|undefined}} param0
  141. * @param {boolean} isLonLat -是否是经纬度坐标
  142. */
  143. flyTo({ destination, orientation }, isLonLat = false) {
  144. if (isLonLat)
  145. destination = Cesium.Cartesian3.fromDegrees(
  146. destination.x,
  147. destination.y,
  148. destination.z || 0
  149. );
  150. viewer.camera.flyTo({
  151. destination,
  152. orientation,
  153. });
  154. },
  155. },
  156. watch: {
  157. poiSearchText: function () {
  158. this.page = 1;
  159. this.poiquery();
  160. },
  161. },
  162. };
  163. </script>