tab-cmap.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <CrMap ref="cmap"></CrMap>
  3. <view class="cr-tools-left">
  4. <ToolButton v-for="(item, index) in leftTools" :id="item.id" :title="item.title" :describe="item.describe" :icon="item.icon" @onclick="onToolsClick" />
  5. </view>
  6. <view class="cr-tools-right">
  7. <ToolButton v-for="(item, index) in rightTools" :id="item.id" :title="item.title" :describe="item.describe" :icon="item.icon" @onclick="onToolsClick" />
  8. </view>
  9. <van-popup v-model:show="showRightPopup" position="right" :style="{ width: '300px', height: 'calc(100% - 51px)', top: 'calc(50% - 25px)' }" :overlay="showOverlay">
  10. <div class="cr-popup-content">
  11. <div class="cr-poput-nav" @click="showRightPopup = false">
  12. <span class="cr-poput-nav-title">{{ poputNavTitle }}</span>
  13. </div>
  14. <div class="cr-popup-child-content">
  15. <div class="cr-color-label">R分量 {{ color.red }}</div>
  16. <van-slider v-model="color.red" :min="0" :max="255" bar-height="4px" active-color="#ee0a24">
  17. <template #button>
  18. <div class="jt-slider-button"></div>
  19. </template>
  20. </van-slider>
  21. <div class="cr-color-label">G分量 {{ color.green }}</div>
  22. <van-slider v-model="color.green" :min="0" :max="255" bar-height="4px" active-color="#ee0a24">
  23. <template #button>
  24. <div class="jt-slider-button"></div>
  25. </template>
  26. </van-slider>
  27. <div class="cr-color-label">B分量 {{ color.blue }}</div>
  28. <van-slider v-model="color.blue" :min="0" :max="255" bar-height="4px" active-color="#ee0a24">
  29. <template #button>
  30. <div class="jt-slider-button"></div>
  31. </template>
  32. </van-slider>
  33. <div class="cr-color-label">A分量 {{ color.alpha / 10 }}</div>
  34. <van-slider v-model="color.alpha" :min="0" :max="10" bar-height="4px" active-color="#ee0a24">
  35. <template #button>
  36. <div class="jt-slider-button"></div>
  37. </template>
  38. </van-slider>
  39. <van-field v-model="height" type="digit" label="高度" />
  40. <div class="cr-edit-buttons">
  41. <van-button type="success" @click="submitEdit()">提交修改</van-button>
  42. <van-button type="danger" @click="remove()">删除实体</van-button>
  43. </div>
  44. </div>
  45. </div>
  46. </van-popup>
  47. <jtDialog class="jt-tools-dialog" :showDialog="showDialog" title="图形编辑" height="500px" width="300px" @closeJTDialog="closeDialog">
  48. <el-row :gutter="20">
  49. <el-col :span="8" @click="this.$refs['cmap'].onMouseDrawEditLine()">
  50. <el-avatar shape="circle" :size="50" style="background-color: bisque;"><i class="app-icon app-icon-map-measurelength" /></el-avatar>
  51. <cite>绘制贴地线</cite>
  52. </el-col>
  53. <el-col :span="8" @click="this.$refs['cmap'].onMouseDrawEditPolygon()">
  54. <el-avatar shape="circle" :size="50" style="background-color: azure;"><i class="app-icon app-icon-map-measurelength" /></el-avatar>
  55. <cite>绘制贴地面</cite>
  56. </el-col>
  57. <el-col :span="8">
  58. <el-avatar shape="circle" :size="50" style="background-color: bisque;"><i class="app-icon app-icon-map-measurelength" /></el-avatar>
  59. <cite>绘制空间线</cite>
  60. </el-col>
  61. </el-row>
  62. <el-row :gutter="20">
  63. <el-col :span="8" @click="this.$refs['cmap'].onMouseDrawEditRectangle()">
  64. <el-avatar shape="circle" :size="50" style="background-color: bisque;"><i class="app-icon app-icon-map-measurelength" /></el-avatar>
  65. <cite>绘制矩形</cite>
  66. </el-col>
  67. <el-col :span="8" @click="this.$refs['cmap'].onMouseDrawEditCircle()">
  68. <el-avatar shape="circle" :size="50" style="background-color: azure;"><i class="app-icon app-icon-map-measurelength" /></el-avatar>
  69. <cite>绘制圆</cite>
  70. </el-col>
  71. <el-col :span="8" @click="this.$refs['cmap'].onMouseDrawEditWall()">
  72. <el-avatar shape="circle" :size="50" style="background-color: bisque;"><i class="app-icon app-icon-map-measurelength" /></el-avatar>
  73. <cite>绘制墙</cite>
  74. </el-col>
  75. </el-row>
  76. <el-row :gutter="20">
  77. <el-col :span="8">
  78. <el-avatar shape="circle" :size="50" style="background-color: bisque;"><i class="app-icon app-icon-map-measurelength" /></el-avatar>
  79. <cite>不规则体</cite>
  80. </el-col>
  81. <el-col :span="8">
  82. <el-avatar shape="circle" :size="50" style="background-color: azure;"><i class="app-icon app-icon-map-measurelength" /></el-avatar>
  83. <cite>绘制圆</cite>
  84. </el-col>
  85. <el-col :span="8" @click="this.$refs['cmap'].onClearDraw()">
  86. <el-avatar shape="circle" :size="50" style="background-color: bisque;"><i class="app-icon app-icon-map-clean" /></el-avatar>
  87. <cite>清除绘制</cite>
  88. </el-col>
  89. </el-row>
  90. </jtDialog>
  91. <!-- 墙的编辑框 -->
  92. <jtWallDialog></jtWallDialog>
  93. </template>
  94. <script setup>
  95. import { Dialog } from 'vant';
  96. /* 引入弹出对话框 */
  97. import jtDialog from '../components/jt-dialog/dialog.vue';
  98. /* 引入墙的编辑对话框 */
  99. import jtWallDialog from '../components/jt-dialog/dialog-wall-edit.vue';
  100. </script>
  101. <script>
  102. /* 引入三维地图控件 */
  103. import CrMap from '../components/CrMap/CrMap.vue';
  104. import { ref } from 'vue';
  105. /* 引入工具按钮 */
  106. import ToolButtom from '../components/ToolButton/ToolButton.vue';
  107. export default {
  108. components: {
  109. CrMap
  110. },
  111. /* 返回数据 */
  112. data() {
  113. return {
  114. leftTools: [],
  115. rightTools: [],
  116. showRightPopup: false,
  117. showOverlay: false,
  118. poputNavTitle: '物体样式调整',
  119. color: {
  120. red: 0,
  121. green: 100,
  122. blue: 255,
  123. alpha: 6
  124. },
  125. height: 120,
  126. dialogVisible: false,
  127. showDialog: false
  128. };
  129. },
  130. /* 创建 */
  131. created() {
  132. /* 工具标题初始化 */
  133. this.leftTools.push({
  134. title: '长度量测',
  135. describe: '在地图上点击需要测量对象的特征位置,即可实时计算长度并展示',
  136. icon: 'app-icon-map-measurelength',
  137. id: 'length'
  138. });
  139. this.leftTools.push({
  140. title: '面积量测',
  141. describe: '在地图上点击需要测量的对象特征位置,即可实时计算面积并展示',
  142. icon: 'app-icon-map-measurearea',
  143. id: 'area'
  144. });
  145. this.leftTools.push({
  146. title: '高度测量',
  147. describe: '在地图上点击需要测量的对象特征位置,即可实时计算高度并展示',
  148. icon: 'app-icon-map-measureheight',
  149. id: 'height'
  150. });
  151. this.leftTools.push({
  152. title: '空间测量',
  153. describe: '在地图上点击需要测量的对象特征位置,即可实时计算空间距离并展示',
  154. icon: 'app-icon-map-measurespace',
  155. id: 'space'
  156. });
  157. this.leftTools.push({
  158. title: '三角测量',
  159. describe: '在地图上点击需要测量对象的特征位置,即可实时计算长度并展示',
  160. icon: 'app-icon-map-measuretriangle',
  161. id: 'triangle'
  162. });
  163. this.leftTools.push({
  164. title: '绘制房屋',
  165. describe: '在地图上单击绘制底部,右键结束绘制拉伸',
  166. icon: 'app-icon-map-house',
  167. id: 'house'
  168. });
  169. this.leftTools.push({
  170. title: '重置地图',
  171. describe: '点击即可重置地图范围为初始显示范围',
  172. icon: 'app-icon-map-initlocation',
  173. id: 'initMapExtent'
  174. });
  175. this.leftTools.push({
  176. title: '坐标查询',
  177. describe: '在地图上需要查询坐标的位置上点击,即可查询该位置的地理坐标',
  178. icon: 'app-icon-map-querycoord',
  179. id: 'coordQuery'
  180. });
  181. this.leftTools.push({
  182. title: '坐标定位',
  183. describe: '点击后,弹出坐标输入框,输入正确的位置坐标后点击定位,即可在地图上展示坐标位置',
  184. icon: 'app-icon-map-inputcoord-location',
  185. id: 'inputLocation'
  186. });
  187. this.leftTools.push({
  188. title: '相机视角',
  189. describe: '点击后,弹出坐标输入框,输入正确的位置坐标后点击定位,即可在地图上展示坐标位置',
  190. icon: 'app-icon-map-camera-view',
  191. id: 'cameraView'
  192. });
  193. this.leftTools.push({
  194. title: '物体拾取',
  195. describe: '点击后,在地图上的实体上单击,即可拾取该实体',
  196. icon: 'app-icon-map-pick',
  197. id: 'pick'
  198. });
  199. this.rightTools.push({
  200. title: '图层管理',
  201. describe: '点击即可打开图层控制窗口,进行图层及标注的显示/隐藏',
  202. icon: 'app-icon-map-layer',
  203. id: 'layerControl'
  204. });
  205. this.rightTools.push({
  206. title: '点击查询',
  207. describe: '点击后,在需要查询的位置单击,即可查询该位置的全部可见图层数据',
  208. icon: 'app-icon-map-query-point',
  209. id: 'queryByPoint'
  210. });
  211. this.rightTools.push({
  212. title: '多点查询',
  213. describe: '点击后,在需要查询的位置单击,即可查询该位置的全部可见图层数据',
  214. icon: 'app-icon-map-query-multiple-point',
  215. id: 'queryByMultiplePoint'
  216. });
  217. this.rightTools.push({
  218. title: '线查询',
  219. describe: '点击后,在需要查询的位置单击,即可查询该位置的全部可见图层数据',
  220. icon: 'app-icon-map-query-point',
  221. id: 'queryByLine'
  222. });
  223. this.rightTools.push({
  224. title: '圆查询',
  225. describe: '点击后,在需要查询的位置单击,即可查询该位置的全部可见图层数据',
  226. icon: 'app-icon-map-query-point',
  227. id: 'queryByCircle'
  228. });
  229. this.rightTools.push({
  230. title: '矩形查询',
  231. describe: '点击后,在需要查询的位置单击,即可查询该位置的全部可见图层数据',
  232. icon: 'app-icon-map-query-point',
  233. id: 'queryByRectangle'
  234. });
  235. this.rightTools.push({
  236. title: '区域查询',
  237. describe: '点击后,在地图上绘制查询区域,单击开始查询,即可查询该区域内的全部可见图层数据',
  238. icon: 'app-icon-map-query-polygon',
  239. id: 'queryByPolygon'
  240. });
  241. this.rightTools.push({
  242. title: '清扫工具',
  243. describe: '清除地图上的各类绘制内容',
  244. icon: 'app-icon-map-clean',
  245. id: 'clear'
  246. });
  247. },
  248. methods: {
  249. /**
  250. * 工具点击事件
  251. * @param {String} toolsId 工具Id
  252. */
  253. onToolsClick(toolsId) {
  254. let _self = this;
  255. switch (toolsId) {
  256. case 'length':
  257. _self.$refs['cmap'].onMeasureLength();
  258. break;
  259. case 'area':
  260. _self.$refs['cmap'].onMeasureArea();
  261. break;
  262. case 'height':
  263. _self.$refs['cmap'].onMeasureHeight();
  264. break;
  265. case 'space':
  266. _self.$refs['cmap'].onMeasureSpatialLength();
  267. break;
  268. case 'triangle':
  269. _self.$refs['cmap'].onMeasureTriangle();
  270. break;
  271. case 'clear':
  272. _self.$refs['cmap'].onClear();
  273. break;
  274. case 'queryByPolygon':
  275. _self.$refs['cmap'].onQueryByPolygon();
  276. break;
  277. case 'queryByPoint':
  278. _self.$refs['cmap'].onQueryByPoint();
  279. break;
  280. case 'queryByMultiplePoint':
  281. _self.$refs['cmap'].onQueryByMultiplePoint();
  282. break;
  283. case 'queryByLine':
  284. _self.$refs['cmap'].onQueryByLine();
  285. break;
  286. case 'queryByCircle':
  287. _self.$refs['cmap'].onQueryByCircle();
  288. break;
  289. case 'queryByRectangle':
  290. _self.$refs['cmap'].onQueryByRectangle();
  291. break;
  292. case 'layerControl':
  293. // _self.$refs['cmap'].onTestDemo();
  294. this.showDialog = true;
  295. break;
  296. case 'cameraView':
  297. _self.$refs['cmap'].onGetCameraViewer();
  298. break;
  299. case 'house':
  300. _self.$refs['cmap'].onDrawPolygonBody();
  301. break;
  302. case 'pick':
  303. _self.$refs['cmap'].onPickPolygonBody(function(res) {
  304. if (res != undefined) {
  305. _self.showRightPopup = true;
  306. _self.color.red = res.color[0];
  307. _self.color.green = res.color[1];
  308. _self.color.blue = res.color[2];
  309. _self.color.alpha = res.color[3] * 10;
  310. _self.height = res.height;
  311. }
  312. });
  313. break;
  314. case 'inputLocation':
  315. // this.showRightPopup = true;
  316. let points = [118.163976, 35.01653, 118.164976, 35.01453, 118.162976, 35.01453];
  317. _self.$refs['cmap'].onDrawFeacture(points);
  318. break;
  319. default:
  320. // Dialog.alert({
  321. // title: '点击了',
  322. // message: toolsId
  323. // });
  324. this.dialogVisible = true;
  325. break;
  326. }
  327. },
  328. /**
  329. * 提交更改
  330. */
  331. submitEdit() {
  332. let _self = this;
  333. let color = [];
  334. color.push(this.color.red);
  335. color.push(this.color.green);
  336. color.push(this.color.blue);
  337. color.push(this.color.alpha / 10);
  338. this.$refs['cmap'].onSetPolygonBody({
  339. color: color,
  340. height: parseFloat(_self.height),
  341. onComplete: function(message) {
  342. if (message == undefined) _self.showRightPopup = false;
  343. else console.log('设置错误', message);
  344. }
  345. });
  346. },
  347. /**
  348. * 移除
  349. */
  350. remove() {
  351. let _self = this;
  352. this.$refs['cmap'].onRemovePolygonBody(function(message) {
  353. if (message == undefined) _self.showRightPopup = false;
  354. else console.log('移除错误', message);
  355. });
  356. },
  357. closeDialog() {
  358. this.showDialog = false;
  359. }
  360. }
  361. };
  362. </script>
  363. <style lang="scss" scoped>
  364. .cr-color-label {
  365. padding-left: 15px;
  366. height: 30px;
  367. line-height: 30px;
  368. color: rgb(144, 225, 255);
  369. font-weight: bold;
  370. text-align: left;
  371. background-color: rgb(29, 99, 248);
  372. }
  373. /* 弹框子内容容器样式 */
  374. .cr-popup-content .cr-popup-child-content {
  375. padding: 10px;
  376. display: flex;
  377. flex-direction: column;
  378. width: calc(100% - 20px);
  379. }
  380. /* 弹出框 主要内容 子内容子项通用样式 */
  381. .cr-popup-content .cr-popup-child-content > * {
  382. margin: 10px 0px;
  383. font-family: 'Alimama_ShuHeiTi_Bold' !important;
  384. }
  385. /* 临时设置帧率位置 */
  386. .cesium-performanceDisplay-defaultContainer {
  387. top: unset;
  388. bottom: 80px;
  389. right: unset;
  390. left: 10px;
  391. }
  392. .jt-slider-button {
  393. width: 20px;
  394. height: 18px;
  395. color: rgb(202, 94, 92);
  396. font-size: 10px;
  397. line-height: 18px;
  398. text-align: center;
  399. background-color: rgb(202, 94, 92);
  400. border-radius: 100px;
  401. }
  402. .van-slider {
  403. margin: 10px !important;
  404. width: calc(100% - 20px) !important;
  405. }
  406. .cr-edit-buttons {
  407. display: flex;
  408. flex-direction: row;
  409. }
  410. .cr-edit-buttons > * {
  411. flex: 1;
  412. margin-left: 8px !important;
  413. height: 34px !important;
  414. }
  415. .cr-edit-buttons > :first-child {
  416. margin-left: 0px !important;
  417. }
  418. /* 工具框样式 */
  419. .jt-tools-dialog {
  420. .el-col {
  421. padding: 10px;
  422. }
  423. .el-col:hover {
  424. cursor: pointer;
  425. background-color: rgba(0, 0, 0, 0.5);
  426. }
  427. i {
  428. display: inline-block;
  429. width: 100%;
  430. height: 36px;
  431. line-height: 36px;
  432. text-align: center;
  433. border-radius: 5px;
  434. font-size: 30px;
  435. color: rgba(252, 152, 0, 1);
  436. transition: all 0.3s;
  437. -webkit-transition: all 0.3s;
  438. }
  439. cite {
  440. position: relative;
  441. top: 5px;
  442. display: block;
  443. color: rgba(255, 255, 255, 1);
  444. text-overflow: ellipsis;
  445. overflow: hidden;
  446. white-space: nowrap;
  447. font-size: 14px;
  448. font-style: normal;
  449. text-align: center;
  450. font-family: 'Alimama_ShuHeiTi_Bold';
  451. }
  452. }
  453. </style>