Blame view

src/components/system/ViewMap.vue 1.97 KB
59fd5759   王彪总   feat(map): 替换腾讯地图...
1
  <template>
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
2
3
4
5
6
7
8
9
10
    <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">
59fd5759   王彪总   feat(map): 替换腾讯地图...
11
        <div id="qqmapcontainer" style="width: 100%; height: 500px;"></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
        } else {
          this.viewMapInfo.lat = 36.72
          this.viewMapInfo.lng = 100.985
        }
  
        this.$nextTick(() => this.initMap())
      },
      initMap() {
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
45
        const container = document.getElementById('qqmapcontainer')
59fd5759   王彪总   feat(map): 替换腾讯地图...
46
47
48
49
        if (!container) return
  
        this.viewMapInfo.map = new window.AMap.Map(container, {
          center: [this.viewMapInfo.lng, this.viewMapInfo.lat],
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
50
          zoom: 17.2,
59fd5759   王彪总   feat(map): 替换腾讯地图...
51
          resizeEnable: true
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
52
        })
59fd5759   王彪总   feat(map): 替换腾讯地图...
53
54
55
  
        new window.AMap.Marker({
          position: [this.viewMapInfo.lng, this.viewMapInfo.lat],
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
56
          map: this.viewMapInfo.map,
59fd5759   王彪总   feat(map): 替换腾讯地图...
57
58
59
60
61
          icon: new window.AMap.Icon({
            size: new window.AMap.Size(25, 35),
            imageSize: new window.AMap.Size(25, 35),
            image: 'https://webapi.amap.com/theme/v1.3/markers/n/mark_r.png'
          })
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
62
63
        })
      },
bd31b865   王彪总   feat(config): 更新开...
64
      closeMap(done) {
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
65
        if (this.viewMapInfo.map) {
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
66
          this.viewMapInfo.map.destroy()
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
67
          this.viewMapInfo.map = null
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
68
        }
bd31b865   王彪总   feat(config): 更新开...
69
70
71
72
        this.viewMapInfo.showMap = false
        if (typeof done === 'function') {
          done()
        }
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
73
74
      },
      wgs84togcj02(lng, lat) {
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
75
        return { lon: lng, lat }
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
76
77
      }
    }
5b51508b   wuxw   v1.9 优化巡检明细 无法点击查看按钮
78
79
80
81
82
83
84
85
  }
  </script>
  
  <style lang="scss" scoped>
  .map-container {
    width: 100%;
    height: 500px;
  }
59fd5759   王彪总   feat(map): 替换腾讯地图...
86
  </style>