tool.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <div class="tool-com __box-shadow">
  3. <div class="item" @click="mapFunc.measure('line')">
  4. <img src="@/assets/images/gis-layout/gis-layout-tools_tool-cjl.png" alt=""/>测距离
  5. </div>
  6. <div class="item" @click="mapFunc.measure('circle')">
  7. <img src="@/assets/images/gis-layout/gis-layout-tools_tool-cymj.png" alt=""/>测圆面积
  8. </div>
  9. <div class="item" @click="mapFunc.measure('rectangle')">
  10. <img src="@/assets/images/gis-layout/gis-layout-tools_tool-cjxmj.png" alt=""/>测矩形面积
  11. </div>
  12. <div class="item" @click="handleDraw({featureType: 'Point'})">
  13. <img src="@/assets/images/gis-layout/gis-layout-tools_tool-bz.png" alt=""/>标注
  14. </div>
  15. <div class="item" @click="handleDraw({featureType: 'LineString'})">
  16. <img src="@/assets/images/gis-layout/gis-layout-tools_tool-hx.png" alt=""/>画线
  17. </div>
  18. <div class="item" @click="handleDraw({featureType: 'Polygon', rectangle: true})">
  19. <img src="@/assets/images/gis-layout/gis-layout-tools_tool-hjx.png" alt=""/>画矩形
  20. </div>
  21. <div class="item" @click="handleDraw({featureType: 'Polygon'})">
  22. <img src="@/assets/images/gis-layout/gis-layout-tools_tool-hdbx.png" alt=""/>画多边形
  23. </div>
  24. <div class="item" @click="handleDraw({featureType: 'Circle'})">
  25. <img src="@/assets/images/gis-layout/gis-layout-tools_tool-hy.png" alt=""/>画圆
  26. </div>
  27. </div>
  28. </template>
  29. <script lang="ts">
  30. import {
  31. defineComponent,
  32. computed,
  33. onMounted,
  34. ref,
  35. reactive,
  36. watch,
  37. getCurrentInstance,
  38. ComponentInternalInstance,
  39. toRefs,
  40. nextTick
  41. } from 'vue'
  42. import {useStore} from 'vuex'
  43. import {useRouter, useRoute} from 'vue-router'
  44. import {ElMessage, ElMessageBox} from "element-plus";
  45. import './map.scss'
  46. import * as ToolDraw from './tool-draw'
  47. import {draw} from "./tool-draw";
  48. import * as BaseDraw from "@/components/easyMap/func/base-draw";
  49. export default defineComponent({
  50. name: '',
  51. components: {},
  52. props: {
  53. map: {
  54. required: true
  55. },
  56. mapFunc: {
  57. required: true
  58. }
  59. },
  60. setup(props, {emit}) {
  61. const store = useStore();
  62. const router = useRouter();
  63. const route = useRoute();
  64. const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
  65. const state = reactive({})
  66. const handleDraw = (obj) => {
  67. const config = Object.assign(ToolDraw.getBaseDrawConfig(), obj)
  68. if (config.featureType === 'Point') {
  69. config.isPoint = true
  70. } else if (config.featureType === 'LineString') {
  71. config.isLineString = true
  72. } else if (config.featureType === 'Polygon') {
  73. config.isPolygon = true
  74. }
  75. ToolDraw.draw(props.map, config)
  76. }
  77. onMounted(() => {
  78. })
  79. return {
  80. ...toRefs(state),
  81. handleDraw
  82. }
  83. },
  84. })
  85. </script>
  86. <style scoped lang="scss">
  87. .tool-com {
  88. padding: 12px 18px;
  89. background-color: #FFFFFF;
  90. .item {
  91. width: 100%;
  92. height: 36px;
  93. display: flex;
  94. align-items: center;
  95. border-radius: 4px;
  96. margin: 4px 0;
  97. cursor: pointer;
  98. &:hover {
  99. background-color: rgba(170, 198, 238, 0.2);
  100. }
  101. >img {
  102. margin: 0 10px;
  103. }
  104. }
  105. }
  106. </style>