CurveLine.vue
2.21 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<script>
import CurveLine from 'bmaplib.curveline'
import commonMixin from '../base/mixins/common.js'
import bindEvents from '../base/bindEvent.js'
import {createPoint} from '../base/factory.js'
const eventList = [
'click',
'dblclick',
'mousedown',
'mouseup',
'mouseout',
'mouseover',
'remove',
'lineupdate'
]
export default {
name: 'bml-curve-line',
render () {},
mixins: [commonMixin('overlay')],
props: {
points: {
type: Array,
default: Array
},
strokeColor: {
type: String
},
strokeWeight: {
type: Number
},
strokeOpacity: {
type: Number
},
strokeStyle: {
type: String
},
massClear: {
type: Boolean,
default: true
},
clicking: {
type: Boolean,
default: true
},
editing: {
type: Boolean,
default: false
}
},
watch: {
points: {
handler (val, oldVal) {
this.originInstance.disableEditing()
this.reload()
},
deep: true
},
strokeColor (val) {
this.originInstance.setStrokeColor(val)
},
strokeOpacity (val) {
this.originInstance.setStrokeOpacity(val)
},
strokeWeight (val) {
this.originInstance.setStrokeWeight(val)
},
strokeStyle (val) {
this.originInstance.setStrokeStyle(val)
},
editing (val) {
val ? this.originInstance.enableEditing() : this.originInstance.disableEditing()
},
massClear (val) {
val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear()
},
clicking (val) {
this.reload()
}
},
methods: {
load () {
const {BMap, map, points, strokeColor, strokeWeight, strokeOpacity, strokeStyle, editing, massClear, clicking} = this
const overlay = new CurveLine(points.map(item => createPoint(BMap, item)), {
strokeColor,
strokeWeight,
strokeOpacity,
strokeStyle,
// enableEditing: editing,
enableMassClear: massClear,
enableClicking: clicking
})
editing ? overlay.enableEditing() : overlay.disableEditing()
this.originInstance = overlay
map.addOverlay(overlay)
bindEvents.call(this, overlay, eventList)
}
}
}
</script>