Blame view

src/components/system/ViewMap.vue 2.22 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
2
3
4
5
6
7
8
9
10
11
    <el-dialog
      :title="$t('common.map')"
      :visible.sync="viewMapInfo.showMap"
      width="80%"
      :before-close="closeMap"
      :close-on-click-modal="false"
      :close-on-press-escape="true"
    >
      <div class="map-container">
        <div id="qqmapcontainer" style="width: 100%; height: 500px; background-color: antiquewhite;"></div>
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
12
      </div>
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
13
14
15
16
17
18
19
20
21
22
23
24
25
    </el-dialog>
  </template>
  
  <script>
  export default {
    name: 'ViewMap',
    data() {
      return {
        viewMapInfo: {
          lat: '',
          lng: '',
          showMap: false,
          map: null
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
26
        }
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
27
28
29
30
31
32
33
      }
    },
    methods: {
      open(param) {
        this.viewMapInfo.showMap = true
  
        if (param.lng && param.lat) {
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
34
35
36
          const lngLat = this.wgs84togcj02(param.lng, param.lat)
          this.viewMapInfo.lat = lngLat.lat
          this.viewMapInfo.lng = lngLat.lon
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
        } else {
          this.viewMapInfo.lat = 36.72
          this.viewMapInfo.lng = 100.985
        }
  
        this.$nextTick(() => this.initMap())
      },
      initMap() {
        const center = new window.TMap.LatLng(this.viewMapInfo.lat, this.viewMapInfo.lng)
        const container = document.getElementById('qqmapcontainer')
        this.viewMapInfo.map = new window.TMap.Map(container, {
          center,
          zoom: 17.2,
          viewMode: '2D'
        })
        new window.TMap.MultiMarker({
          id: 'marker-layer',
          map: this.viewMapInfo.map,
          styles: {
            marker: new window.TMap.MarkerStyle({
              width: 25,
              height: 35,
              anchor: { x: 16, y: 32 },
              src: 'https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/markerDefault.png'
            })
          },
          geometries: [{
            id: 'demo',
            styleId: 'marker',
            position: new window.TMap.LatLng(this.viewMapInfo.lat, this.viewMapInfo.lng),
            properties: { title: 'marker' }
          }]
        })
      },
      closeMap() {
        this.viewMapInfo.showMap = false
        if (this.viewMapInfo.map) {
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
74
          this.viewMapInfo.map.destroy()
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
75
          this.viewMapInfo.map = null
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
76
        }
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
77
78
79
80
      },
      wgs84togcj02(lng, lat) {
        // Placeholder for coordinate conversion
        return { lon: lng, lat }
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
81
82
      }
    }
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
83
84
85
86
87
88
89
90
91
  }
  </script>
  
  <style lang="scss" scoped>
  .map-container {
    width: 100%;
    height: 500px;
  }
  </style>