59fd5759
王彪总
feat(map): 替换腾讯地图...
|
1
|
<template>
|
e0196f8a
wuxw
开发完成admin下巡检任务
|
2
3
4
5
|
<div id="aInspectionTaskMap" class="map-container"></div>
</template>
<script>
|
07e12785
wuxw
v1.9 admin账户中部分页面...
|
6
|
import { queryAdminInspectionTaskDetail } from '@/api/inspection/adminInspectionTaskDetailApi'
|
e0196f8a
wuxw
开发完成admin下巡检任务
|
7
8
9
10
11
12
|
export default {
name: 'AInspectionTaskMap',
data() {
return {
map: null,
|
59fd5759
王彪总
feat(map): 替换腾讯地图...
|
13
14
|
points: [],
markers: []
|
e0196f8a
wuxw
开发完成admin下巡检任务
|
15
16
17
18
19
|
}
},
methods: {
loadData(params) {
console.log(params)
|
e0196f8a
wuxw
开发完成admin下巡检任务
|
20
21
22
23
24
25
26
27
28
29
30
|
},
async initMap(params) {
try {
const { data } = await queryAdminInspectionTaskDetail({
taskId: params.taskId,
page: 1,
row: 1000
})
this.points = data
this.initMapView()
} catch (error) {
|
07e12785
wuxw
v1.9 admin账户中部分页面...
|
31
32
|
console.error(error)
this.$message.error(error)
|
e0196f8a
wuxw
开发完成admin下巡检任务
|
33
34
35
|
}
},
initMapView() {
|
e0196f8a
wuxw
开发完成admin下巡检任务
|
36
37
|
if (!this.points || this.points.length === 0) return
|
59fd5759
王彪总
feat(map): 替换腾讯地图...
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
this.clearMap()
const center = [this.points[0].lng, this.points[0].lat]
this.map = new window.AMap.Map(document.getElementById('aInspectionTaskMap'), {
center: center,
zoom: 17,
resizeEnable: true
})
this.points.forEach(point => {
const isDone = point.state === '20200405'
const icon = new window.AMap.Icon({
size: new window.AMap.Size(25, 35),
imageSize: new window.AMap.Size(25, 35),
image: isDone ? '/img/inspection_done.png' : '/img/inspection.png'
|
e0196f8a
wuxw
开发完成admin下巡检任务
|
53
|
})
|
59fd5759
王彪总
feat(map): 替换腾讯地图...
|
54
55
|
const marker = new window.AMap.Marker({
|
e0196f8a
wuxw
开发完成admin下巡检任务
|
56
|
map: this.map,
|
59fd5759
王彪总
feat(map): 替换腾讯地图...
|
57
58
59
|
position: [point.lng, point.lat],
title: point.inspectionName,
icon: icon
|
e0196f8a
wuxw
开发完成admin下巡检任务
|
60
|
})
|
59fd5759
王彪总
feat(map): 替换腾讯地图...
|
61
62
63
64
65
66
67
68
69
|
this.markers.push(marker)
})
},
clearMap() {
this.markers.forEach(m => m.setMap(null))
this.markers = []
if (this.map) {
this.map.destroy()
this.map = null
|
e0196f8a
wuxw
开发完成admin下巡检任务
|
70
71
|
}
}
|
59fd5759
王彪总
feat(map): 替换腾讯地图...
|
72
73
74
|
},
beforeDestroy() {
this.clearMap()
|
e0196f8a
wuxw
开发完成admin下巡检任务
|
75
76
77
78
79
80
81
82
83
|
}
}
</script>
<style scoped>
.map-container {
height: 600px;
width: 100%;
}
|
59fd5759
王彪总
feat(map): 替换腾讯地图...
|
84
|
</style>
|