pass_b_map_vue2 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/.eslintrc.js +22 -0
  2. package/.github/ISSUE_TEMPLATE.md +7 -0
  3. package/.travis.yml +26 -0
  4. package/CONTRIBUTING.md +27 -0
  5. package/LICENSE +21 -0
  6. package/README.md +52 -0
  7. package/build/compiler.js +127 -0
  8. package/build/webpack.docs.config.js +86 -0
  9. package/build/webpack.prod.config.js +24 -0
  10. package/build/webpack.test.config.js +27 -0
  11. package/components/base/bindEvent.js +11 -0
  12. package/components/base/events.js +120 -0
  13. package/components/base/factory.js +39 -0
  14. package/components/base/mixins/abstract.js +13 -0
  15. package/components/base/mixins/common.js +81 -0
  16. package/components/base/util.js +6 -0
  17. package/components/context-menu/Item.vue +62 -0
  18. package/components/context-menu/Menu.vue +52 -0
  19. package/components/controls/CityList.vue +43 -0
  20. package/components/controls/Control.vue +37 -0
  21. package/components/controls/Copyright.vue +52 -0
  22. package/components/controls/Geolocation.vue +59 -0
  23. package/components/controls/MapType.vue +39 -0
  24. package/components/controls/Navigation.vue +55 -0
  25. package/components/controls/OverviewMap.vue +56 -0
  26. package/components/controls/Panorama.vue +29 -0
  27. package/components/controls/Scale.vue +36 -0
  28. package/components/extra/CurveLine.vue +101 -0
  29. package/components/extra/Heatmap.vue +78 -0
  30. package/components/extra/Lushu.vue +125 -0
  31. package/components/extra/MarkerClusterer.vue +93 -0
  32. package/components/index.js +98 -0
  33. package/components/layers/Tile.vue +53 -0
  34. package/components/layers/Traffic.vue +34 -0
  35. package/components/map/Map.vue +287 -0
  36. package/components/map/MapView.vue +9 -0
  37. package/components/others/AutoComplete.vue +70 -0
  38. package/components/others/Boundary.vue +60 -0
  39. package/components/overlays/Circle.vue +170 -0
  40. package/components/overlays/Ground.vue +65 -0
  41. package/components/overlays/Icon.vue +0 -0
  42. package/components/overlays/InfoWindow.vue +137 -0
  43. package/components/overlays/Label.vue +99 -0
  44. package/components/overlays/Marker.vue +163 -0
  45. package/components/overlays/Overlay.vue +55 -0
  46. package/components/overlays/PointCollection.vue +76 -0
  47. package/components/overlays/Polygon.vue +105 -0
  48. package/components/overlays/Polyline.vue +86 -0
  49. package/components/overlays/Symblo.vue +0 -0
  50. package/components/search/Bus.vue +102 -0
  51. package/components/search/Driving.vue +177 -0
  52. package/components/search/LocalSearch.vue +152 -0
  53. package/components/search/Transit.vue +126 -0
  54. package/components/search/Walking.vue +115 -0
  55. package/index.d.ts +3 -0
  56. package/index.js +1 -0
  57. package/karma.conf.js +44 -0
  58. package/package.json +69 -0
  59. package/test/map.js +37 -0
  60. package/test/util/BMap.mock/Map.js +82 -0
  61. package/test/util/BMap.mock/create-class.js +9 -0
  62. package/test/util/BMap.mock/index.js +5 -0
  63. package/test/util/BMap.mock/spy.js +2 -0
  64. package/test/util/util.js +12 -0
  65. package/types/auto-complete.d.ts +21 -0
  66. package/types/base/base-control.d.ts +12 -0
  67. package/types/base/common.d.ts +127 -0
  68. package/types/boundary.d.ts +40 -0
  69. package/types/bus.d.ts +27 -0
  70. package/types/circle.d.ts +46 -0
  71. package/types/city-list.d.ts +3 -0
  72. package/types/control.d.ts +3 -0
  73. package/types/copyright.d.ts +7 -0
  74. package/types/curve-line.d.ts +36 -0
  75. package/types/driving.d.ts +47 -0
  76. package/types/geolocation.d.ts +18 -0
  77. package/types/ground.d.ts +24 -0
  78. package/types/heatmap.d.ts +29 -0
  79. package/types/index.d.ts +93 -0
  80. package/types/info-window.d.ts +51 -0
  81. package/types/item.d.ts +25 -0
  82. package/types/label.d.ts +35 -0
  83. package/types/local-search.d.ts +62 -0
  84. package/types/lushu.d.ts +53 -0
  85. package/types/map-type.d.ts +13 -0
  86. package/types/map-view.d.ts +3 -0
  87. package/types/map.d.ts +87 -0
  88. package/types/marker-clusterer.d.ts +25 -0
  89. package/types/marker.d.ts +78 -0
  90. package/types/menu.d.ts +7 -0
  91. package/types/navigation.d.ts +18 -0
  92. package/types/overlay.d.ts +16 -0
  93. package/types/overview-map.d.ts +14 -0
  94. package/types/panorama.d.ts +3 -0
  95. package/types/point-collection.d.ts +26 -0
  96. package/types/polygon.d.ts +46 -0
  97. package/types/polyline.d.ts +37 -0
  98. package/types/scale.d.ts +3 -0
  99. package/types/tile.d.ts +21 -0
  100. package/types/traffic.d.ts +8 -0
  101. package/types/transit.d.ts +39 -0
  102. package/types/tsconfig.json +17 -0
  103. package/types/walking.d.ts +35 -0
@@ -0,0 +1,137 @@
1
+ <template>
2
+ <div v-show="show">
3
+ <slot></slot>
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ import commonMixin from '../base/mixins/common.js'
9
+ import bindEvents from '../base/bindEvent.js'
10
+ import {createPoint, createSize} from '../base/factory.js'
11
+
12
+ export default {
13
+ name: 'bm-info-window',
14
+ mixins: [commonMixin('overlay')],
15
+ props: {
16
+ show: {
17
+ type: Boolean
18
+ },
19
+ position: {
20
+ type: Object
21
+ },
22
+ title: {
23
+ type: String
24
+ },
25
+ width: {
26
+ type: Number
27
+ },
28
+ height: {
29
+ type: Number
30
+ },
31
+ maxWidth: {
32
+ type: Number
33
+ },
34
+ offset: {
35
+ type: Object
36
+ },
37
+ maximize: {
38
+ type: Boolean
39
+ },
40
+ autoPan: {
41
+ type: Boolean
42
+ },
43
+ closeOnClick: {
44
+ type: Boolean,
45
+ default: true
46
+ },
47
+ message: {
48
+ type: String
49
+ }
50
+ },
51
+ watch: {
52
+ show (val) {
53
+ val ? this.openInfoWindow() : this.closeInfoWindow()
54
+ },
55
+ 'position.lng' (val, oldVal) {
56
+ this.reload()
57
+ },
58
+ 'position.lat' (val, oldVal) {
59
+ this.reload()
60
+ },
61
+ 'offset.width' (val, oldVal) {
62
+ this.reload()
63
+ },
64
+ 'offset.height' (val) {
65
+ this.reload()
66
+ },
67
+ maxWidth () {
68
+ this.reload()
69
+ },
70
+ width (val) {
71
+ this.originInstance.setWidth(val)
72
+ },
73
+ height (val) {
74
+ this.originInstance.setHeight(val)
75
+ },
76
+ title (val) {
77
+ this.originInstance.setTitle(val)
78
+ },
79
+ maximize (val) {
80
+ val ? this.originInstance.enableMaximize() : this.originInstance.disableMaximize()
81
+ },
82
+ autoPan (val) {
83
+ val ? this.originInstance.enableAutoPan() : this.originInstance.disableAutoPan()
84
+ },
85
+ closeOnClick (val) {
86
+ val ? this.originInstance.enableCloseOnClick() : this.originInstance.disableCloseOnClick()
87
+ }
88
+ },
89
+ methods: {
90
+ redraw () {
91
+ this.originInstance.redraw()
92
+ },
93
+ load () {
94
+ const {BMap, map, show, title, width, height, maxWidth, offset, autoPan, closeOnClick, message, maximize, bindObserver, $parent} = this
95
+ const $content = this.$el
96
+ const overlay = new BMap.InfoWindow($content, {
97
+ width,
98
+ height,
99
+ title,
100
+ maxWidth,
101
+ offset: createSize(BMap, offset),
102
+ enableAutoPan: autoPan,
103
+ enableCloseOnClick: closeOnClick,
104
+ enableMessage: typeof message === 'undefined',
105
+ message
106
+ })
107
+
108
+ maximize ? overlay.enableMaximize() : overlay.disableMaximize()
109
+ bindEvents.call(this, overlay)
110
+ this.originInstance = overlay
111
+ overlay.redraw()
112
+ ;[].forEach.call($content.querySelectorAll('img'), $img => {
113
+ $img.onload = () => overlay.redraw()
114
+ })
115
+ bindObserver()
116
+ this.$container = $parent.originInstance && $parent.originInstance.openInfoWindow ? $parent.originInstance : map
117
+ show && this.openInfoWindow()
118
+ },
119
+ bindObserver () {
120
+ const MutationObserver = global.MutationObserver
121
+ if (!MutationObserver) {
122
+ return
123
+ }
124
+ const {$el, originInstance} = this
125
+ this.observer = new MutationObserver(mutations => originInstance.redraw())
126
+ this.observer.observe($el, {attributes: true, childList: true, characterData: true, subtree: true})
127
+ },
128
+ openInfoWindow () {
129
+ const {BMap, $container, position, originInstance} = this
130
+ $container.openInfoWindow(originInstance, createPoint(BMap, position))
131
+ },
132
+ closeInfoWindow () {
133
+ this.$container.closeInfoWindow(this.originInstance)
134
+ }
135
+ }
136
+ }
137
+ </script>
@@ -0,0 +1,99 @@
1
+ <script>
2
+ import commonMixin from '../base/mixins/common.js'
3
+ import bindEvents from '../base/bindEvent.js'
4
+ import {createPoint, createSize} from '../base/factory.js'
5
+
6
+ export default {
7
+ name: 'bm-label',
8
+ render () {},
9
+ mixins: [commonMixin('overlay')],
10
+ props: {
11
+ content: {
12
+ type: String
13
+ },
14
+ title: {
15
+ type: String
16
+ },
17
+ offset: {},
18
+ position: {},
19
+ labelStyle: {},
20
+ zIndex: {
21
+ type: Number,
22
+ default: 0
23
+ },
24
+ massClear: {
25
+ type: Boolean,
26
+ default: true
27
+ }
28
+ },
29
+ watch: {
30
+ content (val) {
31
+ this.originInstance.setContent(val)
32
+ },
33
+ title (val) {
34
+ this.originInstance.setTitle(val)
35
+ },
36
+ 'offset.width' (val, oldVal) {
37
+ const {BMap} = this
38
+ if (val.toString() !== oldVal.toString()) {
39
+ this.originInstance.setOffset(createSize(BMap, {width: val, height: this.offset.height}))
40
+ }
41
+ },
42
+ 'offset.height' (val, oldVal) {
43
+ const {BMap} = this
44
+ if (val.toString() !== oldVal.toString()) {
45
+ this.originInstance.setOffset(createSize(BMap, {
46
+ width: this.offset.width,
47
+ height: val
48
+ }))
49
+ }
50
+ },
51
+ 'position.lng' (val, oldVal) {
52
+ const {BMap} = this
53
+ const lng = val
54
+ if (val.toString() !== oldVal.toString() && lng >= -180 && lng <= 180) {
55
+ this.originInstance.setCenter(createPoint(BMap, {lng, lat: this.center.lat}))
56
+ }
57
+ },
58
+ 'position.lat' (val, oldVal) {
59
+ const {BMap} = this
60
+ const lat = val
61
+ if (val.toString() !== oldVal.toString() && lat >= -74 && lat <= 74) {
62
+ this.originInstance.setCenter(createPoint(BMap, {lng: this.center.lng, lat}))
63
+ }
64
+ },
65
+ labelStyle: {
66
+ handler (val) {
67
+ this.originInstance.setStyle(val)
68
+ },
69
+ deep: true
70
+ },
71
+ zIndex (val) {
72
+ this.originInstance.setZIndex(val)
73
+ },
74
+ massClear (val) {
75
+ val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear()
76
+ }
77
+ },
78
+ methods: {
79
+ load () {
80
+ const {BMap, map, content, title, offset, position, labelStyle, zIndex, massClear, $parent} = this
81
+ const overlay = new BMap.Label(content, {
82
+ offset: createSize(BMap, offset),
83
+ position: createPoint(BMap, position),
84
+ enableMassClear: massClear
85
+ })
86
+ this.originInstance = overlay
87
+ try {
88
+ $parent.originInstance.setLabel(overlay)
89
+ } catch (e) {
90
+ map.addOverlay(overlay)
91
+ }
92
+ title && overlay.setTitle(title)
93
+ labelStyle && overlay.setStyle(labelStyle)
94
+ zIndex && overlay.setZIndex(zIndex)
95
+ bindEvents.call(this, overlay)
96
+ }
97
+ }
98
+ }
99
+ </script>
@@ -0,0 +1,163 @@
1
+ <template>
2
+ <div>
3
+ <slot></slot>
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ import commonMixin from '../base/mixins/common.js'
9
+ import bindEvents from '../base/bindEvent.js'
10
+ import {createLabel, createIcon, createPoint} from '../base/factory.js'
11
+
12
+ export default {
13
+ name: 'bm-marker',
14
+ mixins: [commonMixin('overlay')],
15
+ props: {
16
+ position: {},
17
+ offset: {},
18
+ icon: {},
19
+ massClear: {
20
+ type: Boolean,
21
+ default: true
22
+ },
23
+ dragging: {
24
+ type: Boolean,
25
+ default: false
26
+ },
27
+ clicking: {
28
+ type: Boolean,
29
+ default: true
30
+ },
31
+ raiseOnDrag: {
32
+ type: Boolean,
33
+ default: false
34
+ },
35
+ draggingCursor: {
36
+ type: String
37
+ },
38
+ rotation: {
39
+ type: Number
40
+ },
41
+ shadow: {
42
+ type: Object
43
+ },
44
+ title: {
45
+ type: String
46
+ },
47
+ label: {
48
+ type: Object
49
+ },
50
+ animation: {
51
+ type: String
52
+ },
53
+ top: {
54
+ type: Boolean,
55
+ default: false
56
+ },
57
+ zIndex: {
58
+ type: Number,
59
+ default: 0
60
+ }
61
+ },
62
+ watch: {
63
+ 'position.lng' (val, oldVal) {
64
+ const {BMap, originInstance, position, renderByParent, $parent} = this
65
+ if (val !== oldVal && val >= -180 && val <= 180) {
66
+ originInstance.setPosition(createPoint(BMap, {lng: val, lat: position.lat}))
67
+ }
68
+ renderByParent && $parent.reload()
69
+ },
70
+ 'position.lat' (val, oldVal) {
71
+ const {BMap, originInstance, position, renderByParent, $parent} = this
72
+ if (val !== oldVal && val >= -74 && val <= 74) {
73
+ originInstance.setPosition(createPoint(BMap, {lng: position.lng, lat: val}))
74
+ }
75
+ renderByParent && $parent.reload()
76
+ },
77
+ 'offset.width' (val, oldVal) {
78
+ const {BMap, originInstance} = this
79
+ if (val !== oldVal) {
80
+ originInstance.setOffset(new BMap.Size(val, this.offset.height))
81
+ }
82
+ },
83
+ 'offset.height' (val, oldVal) {
84
+ const {BMap, originInstance} = this
85
+ if (val !== oldVal) {
86
+ originInstance.setOffset(new BMap.Size(this.offset.width, val))
87
+ }
88
+ },
89
+ icon: {
90
+ deep: true,
91
+ handler (val) {
92
+ const {BMap, originInstance, rotation} = this
93
+ originInstance && originInstance.setIcon(createIcon(BMap, val))
94
+ rotation && originInstance && originInstance.setRotation(rotation)
95
+ }
96
+ },
97
+ massClear (val) {
98
+ val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear()
99
+ },
100
+ dragging (val) {
101
+ val ? this.originInstance.enableDragging() : this.originInstance.disableDragging()
102
+ },
103
+ clicking () {
104
+ this.reload()
105
+ },
106
+ raiseOnDrag () {
107
+ this.reload()
108
+ },
109
+ draggingCursor (val) {
110
+ this.originInstance.setDraggingCursor(val)
111
+ },
112
+ rotation (val) {
113
+ this.originInstance.setRotation(val)
114
+ },
115
+ shadow (val) {
116
+ this.originInstance.setShadow(val)
117
+ },
118
+ title (val) {
119
+ this.originInstance.setTitle(val)
120
+ },
121
+ label (val) {
122
+ this.reload()
123
+ },
124
+ animation (val) {
125
+ this.originInstance.setAnimation(global[val])
126
+ },
127
+ top (val) {
128
+ this.originInstance.setTop(val)
129
+ },
130
+ zIndex (val) {
131
+ this.originInstance.setZIndex(val)
132
+ }
133
+ },
134
+ methods: {
135
+ load () {
136
+ const {BMap, map, position, offset, icon, massClear, dragging, clicking, raiseOnDrag, draggingCursor, rotation, shadow, title, label, animation, top, renderByParent, $parent, zIndex} = this
137
+ const overlay = new BMap.Marker(new BMap.Point(position.lng, position.lat), {
138
+ offset,
139
+ icon: icon && createIcon(BMap, icon),
140
+ enableMassClear: massClear,
141
+ enableDragging: dragging,
142
+ enableClicking: clicking,
143
+ raiseOnDrag,
144
+ draggingCursor,
145
+ rotation,
146
+ shadow,
147
+ title
148
+ })
149
+ this.originInstance = overlay
150
+ label && overlay && overlay.setLabel(createLabel(BMap, label))
151
+ overlay.setTop(top)
152
+ overlay.setZIndex(zIndex)
153
+ bindEvents.call(this, overlay)
154
+ if (renderByParent) {
155
+ $parent.reload()
156
+ } else {
157
+ map.addOverlay(overlay)
158
+ }
159
+ overlay.setAnimation(global[animation])
160
+ }
161
+ }
162
+ }
163
+ </script>
@@ -0,0 +1,55 @@
1
+ <template>
2
+ <div>
3
+ <slot></slot>
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ import commonMixin from '../base/mixins/common.js'
9
+
10
+ export default {
11
+ name: 'bm-overlay',
12
+ mixins: [commonMixin('overlay')],
13
+ props: {
14
+ pane: {
15
+ type: String
16
+ }
17
+ },
18
+ watch: {
19
+ pane () {
20
+ this.reload()
21
+ }
22
+ },
23
+ methods: {
24
+ load () {
25
+ const {BMap, map, $el, pane} = this
26
+ const $emit = this.$emit.bind(this)
27
+ class CustomOverlay extends BMap.Overlay {
28
+ initialize () {
29
+ $emit('initialize', {
30
+ BMap,
31
+ map,
32
+ el: $el,
33
+ overlay: this
34
+ })
35
+ try {
36
+ map.getPanes()[pane].appendChild($el)
37
+ } catch (e) {}
38
+ return $el
39
+ }
40
+ draw () {
41
+ $emit('draw', {
42
+ BMap,
43
+ map,
44
+ el: $el,
45
+ overlay: this
46
+ })
47
+ }
48
+ }
49
+ const overlay = new CustomOverlay()
50
+ this.originInstance = overlay
51
+ map.addOverlay(overlay)
52
+ }
53
+ }
54
+ }
55
+ </script>
@@ -0,0 +1,76 @@
1
+ <script>
2
+ import commonMixin from '../base/mixins/common.js'
3
+ import bindEvents from '../base/bindEvent.js'
4
+ import {createPoint} from '../base/factory.js'
5
+
6
+ export default {
7
+ render () {},
8
+ name: 'bm-point-collection',
9
+ mixins: [commonMixin('overlay')],
10
+ props: {
11
+ points: {
12
+ type: Array,
13
+ default () {
14
+ return []
15
+ }
16
+ },
17
+ shape: {
18
+ type: String,
19
+ default: 'BMAP_POINT_SHAPE_CIRCLE'
20
+ },
21
+ color: {
22
+ type: String
23
+ },
24
+ size: {
25
+ type: String,
26
+ default: 'BMAP_POINT_SIZE_NORMAL'
27
+ }
28
+ },
29
+ watch: {
30
+ shape (val) {
31
+ const {originInstance, color, size} = this
32
+ originInstance.setStyles({
33
+ shape: global[val],
34
+ color,
35
+ size: global[size]
36
+ })
37
+ },
38
+ size (val) {
39
+ const {originInstance, color, shape} = this
40
+ originInstance.setStyles({
41
+ shape: global[shape],
42
+ color,
43
+ size: global[val]
44
+ })
45
+ },
46
+ color (val) {
47
+ const {originInstance, shape, size} = this
48
+ originInstance.setStyles({
49
+ shape: global[shape],
50
+ color: val,
51
+ size: global[size]
52
+ })
53
+ },
54
+ points: {
55
+ deep: true,
56
+ handler (val) {
57
+ const {originInstance} = this
58
+ originInstance.clear()
59
+ originInstance.setPoints(val)
60
+ }
61
+ }
62
+ },
63
+ methods: {
64
+ load () {
65
+ const {BMap, map, points, shape, color, size} = this
66
+ const overlay = this.originInstance = new BMap.PointCollection(points.map(p => createPoint(BMap, p)), {
67
+ shape: global[shape],
68
+ color,
69
+ size: global[size]
70
+ })
71
+ bindEvents.call(this, overlay)
72
+ map.addOverlay(overlay)
73
+ }
74
+ }
75
+ }
76
+ </script>
@@ -0,0 +1,105 @@
1
+ <script>
2
+ import commonMixin from '../base/mixins/common.js'
3
+ import bindEvents from '../base/bindEvent.js'
4
+ import {createPoint} from '../base/factory.js'
5
+
6
+ export default {
7
+ name: 'bm-polygon',
8
+ render () {},
9
+ mixins: [commonMixin('overlay')],
10
+ props: {
11
+ path: {
12
+ type: Array,
13
+ default () {
14
+ return []
15
+ }
16
+ },
17
+ strokeColor: {
18
+ type: String
19
+ },
20
+ strokeWeight: {
21
+ type: Number
22
+ },
23
+ strokeOpacity: {
24
+ type: Number
25
+ },
26
+ strokeStyle: {
27
+ type: String
28
+ },
29
+ fillColor: {
30
+ type: String
31
+ },
32
+ fillOpacity: {
33
+ type: Number
34
+ },
35
+ massClear: {
36
+ type: Boolean,
37
+ default: true
38
+ },
39
+ clicking: {
40
+ type: Boolean,
41
+ default: true
42
+ },
43
+ editing: {
44
+ type: Boolean,
45
+ default: false
46
+ }
47
+ },
48
+ watch: {
49
+ path: {
50
+ handler (val, oldVal) {
51
+ this.reload()
52
+ },
53
+ deep: true
54
+ },
55
+ strokeColor (val) {
56
+ this.originInstance.setStrokeColor(val)
57
+ },
58
+ strokeOpacity (val) {
59
+ this.originInstance.setStrokeOpacity(val)
60
+ },
61
+ strokeWeight (val) {
62
+ this.originInstance.setStrokeWeight(val)
63
+ },
64
+ strokeStyle (val) {
65
+ this.originInstance.setStrokeStyle(val)
66
+ },
67
+ fillColor (val) {
68
+ this.originInstance.setFillColor(val)
69
+ },
70
+ fillOpacity (val) {
71
+ this.originInstance.setFillOpacity(val)
72
+ },
73
+ editing (val) {
74
+ val ? this.originInstance.enableEditing() : this.originInstance.disableEditing()
75
+ },
76
+ massClear (val) {
77
+ val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear()
78
+ },
79
+ clicking (val) {
80
+ this.reload()
81
+ }
82
+ },
83
+ methods: {
84
+ load () {
85
+ const {BMap, map, path, strokeColor, strokeWeight, strokeOpacity, strokeStyle, fillColor, fillOpacity, editing, massClear, clicking} = this
86
+ const overlay = new BMap.Polygon(path.map(item => createPoint(BMap, {lng: item.lng, lat: item.lat})), {
87
+ strokeColor,
88
+ strokeWeight,
89
+ strokeOpacity,
90
+ strokeStyle,
91
+ fillColor,
92
+ fillOpacity,
93
+ // enableEditing: editing,
94
+ enableMassClear: massClear,
95
+ enableClicking: clicking
96
+ })
97
+ this.originInstance = overlay
98
+ map.addOverlay(overlay)
99
+ bindEvents.call(this, overlay)
100
+ // 这里有一个诡异的bug,直接给 editing 赋值时会出现未知错误,因为使用下面的方法抹平。
101
+ editing ? overlay.enableEditing() : overlay.disableEditing()
102
+ }
103
+ }
104
+ }
105
+ </script>
@@ -0,0 +1,86 @@
1
+ <script>
2
+ import commonMixin from '../base/mixins/common.js'
3
+ import bindEvents from '../base/bindEvent.js'
4
+ import {createPoint} from '../base/factory.js'
5
+
6
+ export default {
7
+ name: 'bm-polyline',
8
+ render () {},
9
+ mixins: [commonMixin('overlay')],
10
+ props: {
11
+ path: {
12
+ type: Array
13
+ },
14
+ strokeColor: {
15
+ type: String
16
+ },
17
+ strokeWeight: {
18
+ type: Number
19
+ },
20
+ strokeOpacity: {
21
+ type: Number
22
+ },
23
+ strokeStyle: {
24
+ type: String
25
+ },
26
+ massClear: {
27
+ type: Boolean,
28
+ default: true
29
+ },
30
+ clicking: {
31
+ type: Boolean,
32
+ default: true
33
+ },
34
+ editing: {
35
+ type: Boolean,
36
+ default: false
37
+ }
38
+ },
39
+ watch: {
40
+ path: {
41
+ handler (val, oldVal) {
42
+ this.reload()
43
+ },
44
+ deep: true
45
+ },
46
+ strokeColor (val) {
47
+ this.originInstance.setStrokeColor(val)
48
+ },
49
+ strokeOpacity (val) {
50
+ this.originInstance.setStrokeOpacity(val)
51
+ },
52
+ strokeWeight (val) {
53
+ this.originInstance.setStrokeWeight(val)
54
+ },
55
+ strokeStyle (val) {
56
+ this.originInstance.setStrokeStyle(val)
57
+ },
58
+ editing (val) {
59
+ val ? this.originInstance.enableEditing() : this.originInstance.disableEditing()
60
+ },
61
+ massClear (val) {
62
+ val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear()
63
+ },
64
+ clicking (val) {
65
+ this.reload()
66
+ }
67
+ },
68
+ methods: {
69
+ load () {
70
+ const {BMap, map, path, strokeColor, strokeWeight, strokeOpacity, strokeStyle, editing, massClear, clicking} = this
71
+ const overlay = new BMap.Polyline(path.map(item => createPoint(BMap, {lng: item.lng, lat: item.lat})), {
72
+ strokeColor,
73
+ strokeWeight,
74
+ strokeOpacity,
75
+ strokeStyle,
76
+ enableEditing: editing,
77
+ enableMassClear: massClear,
78
+ enableClicking: clicking
79
+ })
80
+ this.originInstance = overlay
81
+ map.addOverlay(overlay)
82
+ bindEvents.call(this, overlay)
83
+ }
84
+ }
85
+ }
86
+ </script>