-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapInfoWindow.vue
55 lines (54 loc) · 1.15 KB
/
MapInfoWindow.vue
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
<template>
<div>
<div ref="content">
<slot/>
</div>
</div>
</template>
<script>
import mapLayer from '@/components/map/mixins/mapLayer'
import MapMarker from '@/components/map/MapMarker'
export default {
name: 'MapInfoWindow',
mixins: [mapLayer],
props: {
parent: Object
},
data() {
return {
showing: true
}
},
created () {
let parent = this.parent
let parentName = this.$parent.$options.name
if(!parent && parentName == 'MapMarker') {
parent = this.$parent.instance
}
this.instance = this.getMap().addInfoWindow(this.position, parent)
this.instance.onClose(() => {
this.showing = false
this.$emit('close', this)
})
},
mounted () {
this.instance.setContent(this.$refs.content)
},
watch: {
position (pos) {
this.instance.setPosition(pos)
},
parent (p) {
this.instance.setParent(p)
this.instance.open()
},
showing (yes) {
if(yes) {
this.instance.open()
} else {
this.instance.close()
}
}
},
}
</script>