Blame view

src/components/inspection/AInspectionRouteMap.vue 2.11 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
e0196f8a   wuxw   开发完成admin下巡检任务
2
3
4
5
6
7
8
9
10
11
12
13
14
15
    <div id="aInspectionRouteMap" class="map-container"></div>
  </template>
  
  <script>
  import { listAdminInspectionRoutePoints } from '@/api/inspection/aInspectionPlanDetailApi'
  
  export default {
    name: 'AInspectionRouteMap',
    data() {
      return {
        map: null,
        points: []
      }
    },
48ea9c43   wuxw   巡检开发完成
16
17
18
   async created() {
     await this.loadQQMapScript()
    },
e0196f8a   wuxw   开发完成admin下巡检任务
19
    methods: {
48ea9c43   wuxw   巡检开发完成
20
21
22
23
24
25
26
27
28
29
30
31
32
      loadQQMapScript() {
        if (window.TMap) {
          return Promise.resolve();
        }
        
        return new Promise((resolve, reject) => {
          const script = document.createElement('script');
          script.src = `https://map.qq.com/api/gljs?v=1.exp&key=您的腾讯地图KEY`;
          script.onload = resolve;
          script.onerror = reject;
          document.head.appendChild(script);
        });
      },
e0196f8a   wuxw   开发完成admin下巡检任务
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
      async initMap(params) {
        try {
          const { data } = await listAdminInspectionRoutePoints({
            inspectionRouteId: params.inspectionRouteId,
            page: 1,
            row: 1000
          })
          this.points = data
          this.initMapView()
        } catch (error) {
          this.$message.error(this.$t('common.fetchError'))
        }
      },
      initMapView() {
        if (!this.points || this.points.length === 0) return
  
        // 这里需要根据实际地图API实现地图初始化
        // 示例代码,需要替换为实际地图API调用
        console.log('Initialize map with points:', this.points)
48ea9c43   wuxw   巡检开发完成
52
  
e0196f8a   wuxw   开发完成admin下巡检任务
53
54
        // 示例:使用腾讯地图API
        if (window.TMap) {
48ea9c43   wuxw   巡检开发完成
55
56
          const center = new window.TMap.LatLng(this.points[0].lat, this.points[0].lng)
          this.map = new window.TMap.Map(document.getElementById('aInspectionRouteMap'), {
e0196f8a   wuxw   开发完成admin下巡检任务
57
58
59
            center: center,
            zoom: 17
          })
48ea9c43   wuxw   巡检开发完成
60
  
e0196f8a   wuxw   开发完成admin下巡检任务
61
62
          // 添加标记点
          const markers = this.points.map(point => ({
48ea9c43   wuxw   巡检开发完成
63
            position: new window.TMap.LatLng(point.lat, point.lng),
e0196f8a   wuxw   开发完成admin下巡检任务
64
65
66
67
            properties: {
              title: point.inspectionName
            }
          }))
48ea9c43   wuxw   巡检开发完成
68
69
  
          new window.TMap.MultiMarker({
e0196f8a   wuxw   开发完成admin下巡检任务
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
            map: this.map,
            geometries: markers
          })
        }
      }
    }
  }
  </script>
  
  <style scoped>
  .map-container {
    height: 600px;
    width: 100%;
  }
  </style>