vue-baidu-map-api-v3 1.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 (89) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +95 -0
  3. package/README.zh.md +97 -0
  4. package/components/base/bindEvent.js +11 -0
  5. package/components/base/events.js +120 -0
  6. package/components/base/factory.js +63 -0
  7. package/components/base/mixins/abstract.js +13 -0
  8. package/components/base/mixins/common.js +81 -0
  9. package/components/base/util.js +6 -0
  10. package/components/context-menu/Item.vue +62 -0
  11. package/components/context-menu/Menu.vue +52 -0
  12. package/components/controls/CityList.vue +43 -0
  13. package/components/controls/Control.vue +37 -0
  14. package/components/controls/Copyright.vue +52 -0
  15. package/components/controls/Geolocation.vue +59 -0
  16. package/components/controls/MapType.vue +39 -0
  17. package/components/controls/Navigation.vue +55 -0
  18. package/components/controls/OverviewMap.vue +56 -0
  19. package/components/controls/Panorama.vue +29 -0
  20. package/components/controls/Scale.vue +36 -0
  21. package/components/extra/CurveLine.vue +101 -0
  22. package/components/extra/Heatmap.vue +78 -0
  23. package/components/extra/Lushu.vue +125 -0
  24. package/components/extra/MarkerClusterer.vue +93 -0
  25. package/components/index.js +98 -0
  26. package/components/layers/Tile.vue +53 -0
  27. package/components/layers/Traffic.vue +34 -0
  28. package/components/map/Map.vue +302 -0
  29. package/components/map/MapView.vue +9 -0
  30. package/components/others/AutoComplete.vue +70 -0
  31. package/components/others/Boundary.vue +60 -0
  32. package/components/overlays/Circle.vue +170 -0
  33. package/components/overlays/Ground.vue +65 -0
  34. package/components/overlays/Icon.vue +0 -0
  35. package/components/overlays/InfoWindow.vue +137 -0
  36. package/components/overlays/Label.vue +99 -0
  37. package/components/overlays/Marker.vue +163 -0
  38. package/components/overlays/Overlay.vue +55 -0
  39. package/components/overlays/PointCollection.vue +76 -0
  40. package/components/overlays/Polygon.vue +105 -0
  41. package/components/overlays/Polyline.vue +107 -0
  42. package/components/overlays/Symblo.vue +0 -0
  43. package/components/search/Bus.vue +102 -0
  44. package/components/search/Driving.vue +177 -0
  45. package/components/search/LocalSearch.vue +152 -0
  46. package/components/search/Transit.vue +126 -0
  47. package/components/search/Walking.vue +115 -0
  48. package/index.js +1 -0
  49. package/package.json +104 -0
  50. package/types/auto-complete.d.ts +22 -0
  51. package/types/base/base-control.d.ts +14 -0
  52. package/types/base/common.d.ts +171 -0
  53. package/types/base/component.d.ts +5 -0
  54. package/types/boundary.d.ts +41 -0
  55. package/types/bus.d.ts +28 -0
  56. package/types/circle.d.ts +47 -0
  57. package/types/city-list.d.ts +3 -0
  58. package/types/control.d.ts +3 -0
  59. package/types/copyright.d.ts +7 -0
  60. package/types/curve-line.d.ts +37 -0
  61. package/types/driving.d.ts +48 -0
  62. package/types/geolocation.d.ts +18 -0
  63. package/types/ground.d.ts +25 -0
  64. package/types/heatmap.d.ts +29 -0
  65. package/types/index.d.ts +93 -0
  66. package/types/info-window.d.ts +52 -0
  67. package/types/item.d.ts +26 -0
  68. package/types/label.d.ts +36 -0
  69. package/types/local-search.d.ts +63 -0
  70. package/types/lushu.d.ts +54 -0
  71. package/types/map-type.d.ts +13 -0
  72. package/types/map-view.d.ts +4 -0
  73. package/types/map.d.ts +88 -0
  74. package/types/marker-clusterer.d.ts +26 -0
  75. package/types/marker.d.ts +79 -0
  76. package/types/menu.d.ts +8 -0
  77. package/types/navigation.d.ts +18 -0
  78. package/types/overlay.d.ts +17 -0
  79. package/types/overview-map.d.ts +14 -0
  80. package/types/panorama.d.ts +3 -0
  81. package/types/point-collection.d.ts +27 -0
  82. package/types/polygon.d.ts +47 -0
  83. package/types/polyline.d.ts +43 -0
  84. package/types/scale.d.ts +3 -0
  85. package/types/tile.d.ts +22 -0
  86. package/types/traffic.d.ts +9 -0
  87. package/types/transit.d.ts +40 -0
  88. package/types/tsconfig.json +17 -0
  89. package/types/walking.d.ts +36 -0
@@ -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,107 @@
1
+ <script>
2
+ import commonMixin from '../base/mixins/common.js'
3
+ import bindEvents from '../base/bindEvent.js'
4
+ import {createPoint, createIconSequence} 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
+ icons: {
39
+ type: Array,
40
+ default () {
41
+ return []
42
+ }
43
+ }
44
+ },
45
+ watch: {
46
+ path: {
47
+ handler (val, oldVal) {
48
+ this.reload()
49
+ },
50
+ deep: true
51
+ },
52
+ icons: {
53
+ handler (val, oldVal) {
54
+ this.reload()
55
+ },
56
+ deep: true
57
+ },
58
+ strokeColor (val) {
59
+ this.originInstance.setStrokeColor(val)
60
+ },
61
+ strokeOpacity (val) {
62
+ this.originInstance.setStrokeOpacity(val)
63
+ },
64
+ strokeWeight (val) {
65
+ this.originInstance.setStrokeWeight(val)
66
+ },
67
+ strokeStyle (val) {
68
+ this.originInstance.setStrokeStyle(val)
69
+ },
70
+ editing (val) {
71
+ val ? this.originInstance.enableEditing() : this.originInstance.disableEditing()
72
+ },
73
+ massClear (val) {
74
+ val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear()
75
+ },
76
+ clicking (val) {
77
+ this.reload()
78
+ }
79
+ },
80
+ computed: {
81
+ iconSequences () {
82
+ const {BMap, icons} = this
83
+ return icons.map(item => {
84
+ return createIconSequence(BMap, item)
85
+ })
86
+ }
87
+ },
88
+ methods: {
89
+ load () {
90
+ const {BMap, map, path, strokeColor, strokeWeight, strokeOpacity, strokeStyle, editing, massClear, clicking, iconSequences} = this
91
+ const overlay = new BMap.Polyline(path.map(item => createPoint(BMap, {lng: item.lng, lat: item.lat})), {
92
+ strokeColor,
93
+ strokeWeight,
94
+ strokeOpacity,
95
+ strokeStyle,
96
+ enableEditing: editing,
97
+ enableMassClear: massClear,
98
+ enableClicking: clicking,
99
+ icons: iconSequences
100
+ })
101
+ this.originInstance = overlay
102
+ map.addOverlay(overlay)
103
+ bindEvents.call(this, overlay)
104
+ }
105
+ }
106
+ }
107
+ </script>
File without changes
@@ -0,0 +1,102 @@
1
+ <template>
2
+ <div v-show="panel">
3
+ </div>
4
+ </template>
5
+
6
+ <script>
7
+ import {createPoint} from '../base/factory.js'
8
+ import {isPoint} from '../base/util.js'
9
+ import commonMixin from '../base/mixins/common.js'
10
+
11
+ export default {
12
+ name: 'bm-bus',
13
+ mixins: [commonMixin('search')],
14
+ props: {
15
+ location: {
16
+ type: [Object, String]
17
+ },
18
+ keyword: {
19
+ type: String
20
+ },
21
+ panel: {
22
+ type: Boolean,
23
+ default: true
24
+ },
25
+ pageCapacity: {
26
+ type: Number
27
+ },
28
+ autoViewport: {
29
+ type: Boolean
30
+ },
31
+ selectFirstResult: {
32
+ type: Boolean
33
+ }
34
+ },
35
+ watch: {
36
+ location: {
37
+ handler (val) {
38
+ const {originInstance, map} = this
39
+ originInstance.setLocation(val || map)
40
+ },
41
+ deep: true
42
+ },
43
+ keyword (val) {
44
+ this.search(val)
45
+ },
46
+ panel () {
47
+ this.reload()
48
+ },
49
+ autoViewport (val) {
50
+ this.reload()
51
+ },
52
+ selectFirstResult (val) {
53
+ this.reload()
54
+ }
55
+ },
56
+ methods: {
57
+ search (keyword) {
58
+ const {originInstance} = this
59
+ originInstance.getBusList(keyword)
60
+ },
61
+ load () {
62
+ const instance = this
63
+ const {location, selectFirstResult, autoViewport, highlightMode, keyword, search, BMap, map, originInstance} = this
64
+ const _location = location ? isPoint(location) ? createPoint(BMap, location) : location : map
65
+ const route = this.originInstance = new BMap.BusLineSearch(_location, {
66
+ renderOptions: {
67
+ map,
68
+ panel: this.$el,
69
+ selectFirstResult,
70
+ autoViewport,
71
+ highlightMode
72
+ },
73
+ onGetBusListComplete (e) {
74
+ if (originInstance && originInstance !== route) {
75
+ originInstance.clearResults()
76
+ }
77
+ instance.$emit('getbuslistcomplete', e)
78
+ },
79
+ onGetBusLineComplete (e) {
80
+ if (originInstance && originInstance !== route) {
81
+ originInstance.clearResults()
82
+ }
83
+ instance.$emit('getbuslinecomplete', e)
84
+ },
85
+ onBusListHtmlSet (e) {
86
+ instance.$emit('buslisthtmlset', e)
87
+ },
88
+ onBusLineHtmlSet (e) {
89
+ instance.$emit('buslinehtmlset', e)
90
+ },
91
+ onMarkersSet (e) {
92
+ instance.$emit('markersset', e)
93
+ },
94
+ onPolylinesSet (e) {
95
+ instance.$emit('polylinesset', e)
96
+ }
97
+ })
98
+ search(keyword)
99
+ }
100
+ }
101
+ }
102
+ </script>
@@ -0,0 +1,177 @@
1
+ <template>
2
+ <div v-show="panel">
3
+ <slot></slot>
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ import {createPoint} from '../base/factory.js'
9
+ import {isPoint, getPosition} from '../base/util.js'
10
+ import commonMixin from '../base/mixins/common.js'
11
+
12
+ export default {
13
+ name: 'bm-driving',
14
+ mixins: [commonMixin('search')],
15
+ props: {
16
+ location: {
17
+ type: [Object, String]
18
+ },
19
+ start: {
20
+ type: [Object, String]
21
+ },
22
+ end: {
23
+ type: [Object, String]
24
+ },
25
+ startCity: {
26
+ type: [String, Number]
27
+ },
28
+ endCity: {
29
+ type: [String, Number]
30
+ },
31
+ waypoints: {
32
+ type: Array
33
+ },
34
+ policy: {
35
+ type: String
36
+ },
37
+ panel: {
38
+ type: Boolean,
39
+ default: true
40
+ },
41
+ autoViewport: {
42
+ type: Boolean
43
+ },
44
+ selectFirstResult: {
45
+ type: Boolean
46
+ }
47
+ },
48
+ watch: {
49
+ location: {
50
+ handler (val) {
51
+ const {originInstance, map} = this
52
+ originInstance.setLocation(val || map)
53
+ },
54
+ deep: true
55
+ },
56
+ start: {
57
+ handler (val) {
58
+ const {originInstance, end, startCity, endCity, waypoints, BMap, getWaypoints} = this
59
+ originInstance.search(getPosition(BMap, val), getPosition(BMap, end), {
60
+ startCity,
61
+ endCity,
62
+ waypoints: getWaypoints(waypoints)
63
+ })
64
+ },
65
+ deep: true
66
+ },
67
+ end: {
68
+ handler (val) {
69
+ const {originInstance, start, startCity, endCity, waypoints, BMap, getWaypoints} = this
70
+ originInstance.search(getPosition(BMap, start), getPosition(BMap, val), {
71
+ startCity,
72
+ endCity,
73
+ waypoints: getWaypoints(waypoints)
74
+ })
75
+ },
76
+ deep: true
77
+ },
78
+ startCity (val) {
79
+ const {originInstance, start, end, endCity, waypoints, getWaypoints} = this
80
+ originInstance.search(start, end, {
81
+ val,
82
+ endCity,
83
+ waypoints: getWaypoints(waypoints)
84
+ })
85
+ },
86
+ endCity (val) {
87
+ const {originInstance, start, end, startCity, waypoints, getWaypoints} = this
88
+ originInstance.search(start, end, {
89
+ startCity,
90
+ val,
91
+ waypoints: getWaypoints(waypoints)
92
+ })
93
+ },
94
+ waypoints: {
95
+ handler (val) {
96
+ const {originInstance, start, end, startCity, endCity, getWaypoints} = this
97
+ originInstance.search(start, end, {
98
+ startCity,
99
+ endCity,
100
+ waypoints: getWaypoints(val)
101
+ })
102
+ },
103
+ deep: true
104
+ },
105
+ panel () {
106
+ this.reload()
107
+ },
108
+ policy (val) {
109
+ this.reload()
110
+ },
111
+ autoViewport () {
112
+ this.reload()
113
+ },
114
+ selectFirstResult () {
115
+ this.reload()
116
+ },
117
+ highlightMode () {
118
+ this.reload()
119
+ }
120
+ },
121
+ methods: {
122
+ search (start, end, {startCity, endCity, waypoints}) {
123
+ const {originInstance, getWaypoints} = this
124
+ originInstance.search(start, end, {
125
+ startCity,
126
+ endCity,
127
+ waypoints: getWaypoints(waypoints)
128
+ })
129
+ },
130
+ getWaypoints (waypoints) {
131
+ const {BMap} = this
132
+ if (waypoints) {
133
+ return waypoints.map(position => getPosition(BMap, position))
134
+ }
135
+ },
136
+ load () {
137
+ const instance = this
138
+ const {map, BMap, location, policy, selectFirstResult, autoViewport, highlightMode, search, start, end, startCity, endCity, waypoints, originInstance, getWaypoints} = this
139
+ const _location = location ? isPoint(location) ? createPoint(BMap, location) : location : map
140
+ const route = this.originInstance = new BMap.DrivingRoute(_location, {
141
+ renderOptions: {
142
+ map,
143
+ // panel: panel && this.$el,
144
+ panel: this.$el,
145
+ selectFirstResult,
146
+ autoViewport,
147
+ highlightMode
148
+ },
149
+ policy: global[policy],
150
+ onSearchComplete (e) {
151
+ if (originInstance && originInstance !== route) {
152
+ originInstance.clearResults()
153
+ }
154
+ instance.$emit('searchcomplete', e)
155
+ },
156
+ onMarkersSet (e) {
157
+ instance.$emit('markersset', e)
158
+ },
159
+ onInfoHtmlSet (e) {
160
+ instance.$emit('infohtmlset', e)
161
+ },
162
+ onPolylinesSet (e) {
163
+ instance.$emit('polylinesset', e)
164
+ },
165
+ onResultsHtmlSet (e) {
166
+ instance.$emit('resultshtmlset', e)
167
+ }
168
+ })
169
+ search(getPosition(BMap, start), getPosition(BMap, end), {
170
+ startCity,
171
+ endCity,
172
+ waypoints: getWaypoints(waypoints)
173
+ })
174
+ }
175
+ }
176
+ }
177
+ </script>