geo-element.vue
1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
<template>
<message-bubble :isMine="isMine" :message=message>
<a class="geo-element" :href="href" target="_blank" title="点击查看详情">
<span class="el-icon-location-outline">{{payload.description}}</span>
<img :src="url" />
</a>
</message-bubble>
</template>
<script>
import MessageBubble from '../message-bubble'
export default {
name: 'GeoElement',
components: {
MessageBubble
},
props: {
payload: {
type: Object,
required: true
},
message: {
type: Object,
required: true
},
isMine: {
type: Boolean
}
},
data() {
return {
url: ''
}
},
computed: {
lon() {
return this.payload.longitude.toFixed(6)
},
lat() {
return this.payload.latitude.toFixed(6)
},
href() {
return `https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&pointx=${
this.lon
}&pointy=${this.lat}&name=${this.payload.description}`
}
},
mounted() {
this.url = `https://apis.map.qq.com/ws/staticmap/v2/?center=${this.lat},${
this.lon
}&zoom=10&size=300*150&maptype=roadmap&markers=size:large|color:0xFFCCFF|label:k|${
this.lat
},${this.lon}&key=UBNBZ-PTP3P-TE7DB-LHRTI-Y4YLE-VWBBD`
}
}
</script>
<style lang="stylus" scoped>
.geo-element {
text-decoration: none;
color: #000;
display: flex;
flex-direction: column;
padding: 6px;
font-size: 18px;
img {
margin-top: 12px;
}
}
</style>