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,37 @@
1
+ <template>
2
+ <div>
3
+ <slot></slot>
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ import commonMixin from '../base/mixins/common.js'
9
+ import {createSize} from '../base/factory.js'
10
+
11
+ export default {
12
+ name: 'bm-control',
13
+ mixins: [commonMixin('control')],
14
+ props: ['anchor', 'offset'],
15
+ watch: {
16
+ anchor (val) {
17
+ this.originInstance.setAnchor(val)
18
+ },
19
+ offset (val) {
20
+ this.originInstance.setOffset(val)
21
+ }
22
+ },
23
+ methods: {
24
+ load () {
25
+ const {BMap, map, anchor, offset, $el} = this
26
+ const Control = function () {
27
+ this.defaultAnchor = global[anchor || 'BMAP_ANCHOR_TOP_LEFT']
28
+ this.defaultOffset = createSize(BMap, offset)
29
+ }
30
+ Control.prototype = new BMap.Control()
31
+ Control.prototype.initialize = map => map.getContainer().appendChild($el)
32
+ this.originInstance = new Control(anchor, offset)
33
+ map.addControl(this.originInstance)
34
+ }
35
+ }
36
+ }
37
+ </script>
@@ -0,0 +1,52 @@
1
+ <script>
2
+ import commonMixin from '../base/mixins/common.js'
3
+ import {createSize} from '../base/factory.js'
4
+
5
+ export default {
6
+ name: 'bm-copyright',
7
+ render () {},
8
+ mixins: [commonMixin('control')],
9
+ props: ['anchor', 'offset', 'copyright'],
10
+ watch: {
11
+ anchor () {
12
+ this.reload()
13
+ },
14
+ offset () {
15
+ this.reload()
16
+ },
17
+ copyright () {
18
+ this.reload()
19
+ }
20
+ },
21
+ methods: {
22
+ load () {
23
+ const {BMap, map, offset, anchor, updateCopyrightList} = this
24
+ this.originInstance = new BMap.CopyrightControl({
25
+ anchor: global[anchor],
26
+ offset: offset && createSize(BMap, offset)
27
+ })
28
+ updateCopyrightList()
29
+ map.addControl(this.originInstance)
30
+ },
31
+ updateCopyrightList () {
32
+ const {BMap, map} = this
33
+ const {removeCopyright, getCopyrightCollection} = this.originInstance
34
+ const copyrightList = getCopyrightCollection()
35
+ copyrightList && copyrightList.forEach(item => {
36
+ removeCopyright(item.id)
37
+ })
38
+ this.copyright && this.copyright.forEach(item => {
39
+ const bounds = item.bounds
40
+ ? new BMap.Bounds(new BMap.Point(item.bounds.sw.lng, item.bounds.sw.lat), new BMap.Point(item.bounds.ne.lng, item.bounds.ne.lat))
41
+ : map.getBounds()
42
+ this.originInstance.addCopyright({
43
+ id: item.id,
44
+ content: item.content,
45
+ bounds
46
+ })
47
+ this.originInstance.getCopyrightCollection()
48
+ })
49
+ }
50
+ }
51
+ }
52
+ </script>
@@ -0,0 +1,59 @@
1
+ <script>
2
+ import commonMixin from '../base/mixins/common.js'
3
+ import bindEvents from '../base/bindEvent.js'
4
+ import {createIcon, createSize} from '../base/factory.js'
5
+
6
+ export default {
7
+ name: 'bm-geolocation',
8
+ render () {},
9
+ mixins: [commonMixin('control')],
10
+ props: {
11
+ anchor: {
12
+ type: String
13
+ },
14
+ offset: {
15
+ type: Object
16
+ },
17
+ showAddressBar: {
18
+ type: Boolean
19
+ },
20
+ autoLocation: {
21
+ type: Boolean
22
+ },
23
+ locationIcon: {
24
+ type: Object
25
+ }
26
+ },
27
+ watch: {
28
+ anchor () {
29
+ this.reload()
30
+ },
31
+ offset () {
32
+ this.reload()
33
+ },
34
+ showAddressBar () {
35
+ this.reload()
36
+ },
37
+ autoLocation () {
38
+ this.reload()
39
+ },
40
+ locationIcon () {
41
+ this.reload()
42
+ }
43
+ },
44
+ methods: {
45
+ load () {
46
+ const {BMap, map, anchor, showAddressBar, autoLocation, locationIcon, offset} = this
47
+ this.originInstance = new BMap.GeolocationControl({
48
+ anchor: global[anchor],
49
+ showAddressBar,
50
+ enableAutoLocation: autoLocation,
51
+ offset: offset && createSize(BMap, offset),
52
+ locationIcon: locationIcon && createIcon(BMap, locationIcon)
53
+ })
54
+ bindEvents.call(this, this.originInstance)
55
+ map.addControl(this.originInstance)
56
+ }
57
+ }
58
+ }
59
+ </script>
@@ -0,0 +1,39 @@
1
+ <script>
2
+ import commonMixin from '../base/mixins/common.js'
3
+ import {createSize} from '../base/factory.js'
4
+
5
+ export default {
6
+ name: 'bm-map-type',
7
+ render () {},
8
+ mixins: [commonMixin('control')],
9
+ props: ['type', 'mapTypes', 'anchor', 'offset'],
10
+ watch: {
11
+ anchor () {
12
+ this.reload()
13
+ },
14
+ offset () {
15
+ this.reload()
16
+ },
17
+ type () {
18
+ this.reload()
19
+ },
20
+ mapTypes () {
21
+ this.reload()
22
+ }
23
+ },
24
+ methods: {
25
+ load () {
26
+ const {BMap, map, anchor, offset, type} = this
27
+ const mapTypes = []
28
+ this.mapTypes && this.mapTypes.forEach(item => mapTypes.push(global[item]))
29
+ this.originInstance = new BMap.MapTypeControl({
30
+ anchor: global[anchor],
31
+ offset: offset && createSize(BMap, offset),
32
+ type: global[type],
33
+ mapTypes
34
+ })
35
+ map.addControl(this.originInstance)
36
+ }
37
+ }
38
+ }
39
+ </script>
@@ -0,0 +1,55 @@
1
+ <script>
2
+ import commonMixin from '../base/mixins/common.js'
3
+ import {createSize} from '../base/factory.js'
4
+
5
+ export default {
6
+ name: 'bm-navigation',
7
+ render () {},
8
+ mixins: [commonMixin('control')],
9
+ props: {
10
+ anchor: {
11
+ type: String
12
+ },
13
+ offset: {
14
+ type: Object
15
+ },
16
+ type: {
17
+ type: String
18
+ },
19
+ showZoomInfo: {
20
+ type: Boolean
21
+ },
22
+ enableGeolocation: {
23
+ type: Boolean,
24
+ default: false
25
+ }
26
+ },
27
+ watch: {
28
+ anchor () {
29
+ this.reload()
30
+ },
31
+ offset () {
32
+ this.reload()
33
+ },
34
+ type () {
35
+ this.reload()
36
+ },
37
+ showZoomInfo () {
38
+ this.reload()
39
+ }
40
+ },
41
+ methods: {
42
+ load () {
43
+ const {BMap, map, anchor, offset, type, showZoomInfo, enableGeolocation} = this
44
+ this.originInstance = new BMap.NavigationControl({
45
+ anchor: global[anchor],
46
+ offset: offset && createSize(BMap, offset),
47
+ type: global[type],
48
+ showZoomInfo,
49
+ enableGeolocation
50
+ })
51
+ map.addControl(this.originInstance)
52
+ }
53
+ }
54
+ }
55
+ </script>
@@ -0,0 +1,56 @@
1
+ <script>
2
+ import {createSize} from '../base/factory.js'
3
+ import commonMixin from '../base/mixins/common.js'
4
+ import bindEvents from '../base/bindEvent.js'
5
+
6
+ export default {
7
+ name: 'bm-overview-map',
8
+ mixins: [commonMixin('control')],
9
+ render () {},
10
+ props: {
11
+ anchor: {
12
+ type: String
13
+ },
14
+ offset: {
15
+ type: Object
16
+ },
17
+ size: {
18
+ type: Object
19
+ },
20
+ isOpen: {
21
+ type: Boolean
22
+ }
23
+ },
24
+ watch: {
25
+ anchor () {
26
+ this.reload()
27
+ },
28
+ offset () {
29
+ this.reload()
30
+ },
31
+ size () {
32
+ this.reload()
33
+ },
34
+ isOpen () {
35
+ this.reload()
36
+ }
37
+ },
38
+ methods: {
39
+ load () {
40
+ const {BMap, map, isOpen, size, offset, anchor} = this
41
+ const mapTypes = []
42
+ this.mapTypes && this.mapTypes.forEach(item => {
43
+ mapTypes.push(global[item])
44
+ })
45
+ this.originInstance = new BMap.OverviewMapControl({
46
+ anchor: global[anchor],
47
+ offset: createSize(BMap, offset),
48
+ size: createSize(BMap, size),
49
+ isOpen
50
+ })
51
+ bindEvents.call(this, this.originInstance)
52
+ map.addControl(this.originInstance)
53
+ }
54
+ }
55
+ }
56
+ </script>
@@ -0,0 +1,29 @@
1
+ <script>
2
+ import commonMixin from '../base/mixins/common.js'
3
+ import {createSize} from '../base/factory.js'
4
+
5
+ export default {
6
+ name: 'bm-panorama',
7
+ mixins: [commonMixin('control')],
8
+ render () {},
9
+ props: ['anchor', 'offset'],
10
+ watch: {
11
+ anchor () {
12
+ this.reload()
13
+ },
14
+ offset () {
15
+ this.reload()
16
+ }
17
+ },
18
+ methods: {
19
+ load () {
20
+ const {BMap, map, anchor, offset} = this
21
+ this.originInstance = new BMap.PanoramaControl({
22
+ anchor: global[anchor],
23
+ offset: offset && createSize(BMap, offset)
24
+ })
25
+ map.addControl(this.originInstance)
26
+ }
27
+ }
28
+ }
29
+ </script>
@@ -0,0 +1,36 @@
1
+ <script>
2
+ import commonMixin from '../base/mixins/common.js'
3
+ import {createSize} from '../base/factory.js'
4
+
5
+ export default {
6
+ name: 'bm-scale',
7
+ render () {},
8
+ mixins: [commonMixin('control')],
9
+ props: {
10
+ anchor: {
11
+ type: String
12
+ },
13
+ offset: {
14
+ type: Object
15
+ }
16
+ },
17
+ watch: {
18
+ anchor () {
19
+ this.reload()
20
+ },
21
+ offset () {
22
+ this.reload()
23
+ }
24
+ },
25
+ methods: {
26
+ load () {
27
+ const {BMap, map, anchor, offset} = this
28
+ this.originInstance = new BMap.ScaleControl({
29
+ anchor: global[anchor],
30
+ offset: offset && createSize(BMap, offset)
31
+ })
32
+ map.addControl(this.originInstance)
33
+ }
34
+ }
35
+ }
36
+ </script>
@@ -0,0 +1,101 @@
1
+ <script>
2
+ import CurveLine from 'bmaplib.curveline'
3
+ import commonMixin from '../base/mixins/common.js'
4
+ import bindEvents from '../base/bindEvent.js'
5
+ import {createPoint} from '../base/factory.js'
6
+
7
+ const eventList = [
8
+ 'click',
9
+ 'dblclick',
10
+ 'mousedown',
11
+ 'mouseup',
12
+ 'mouseout',
13
+ 'mouseover',
14
+ 'remove',
15
+ 'lineupdate'
16
+ ]
17
+
18
+ export default {
19
+ name: 'bml-curve-line',
20
+ render () {},
21
+ mixins: [commonMixin('overlay')],
22
+ props: {
23
+ points: {
24
+ type: Array,
25
+ default: Array
26
+ },
27
+ strokeColor: {
28
+ type: String
29
+ },
30
+ strokeWeight: {
31
+ type: Number
32
+ },
33
+ strokeOpacity: {
34
+ type: Number
35
+ },
36
+ strokeStyle: {
37
+ type: String
38
+ },
39
+ massClear: {
40
+ type: Boolean,
41
+ default: true
42
+ },
43
+ clicking: {
44
+ type: Boolean,
45
+ default: true
46
+ },
47
+ editing: {
48
+ type: Boolean,
49
+ default: false
50
+ }
51
+ },
52
+ watch: {
53
+ points: {
54
+ handler (val, oldVal) {
55
+ this.originInstance.disableEditing()
56
+ this.reload()
57
+ },
58
+ deep: true
59
+ },
60
+ strokeColor (val) {
61
+ this.originInstance.setStrokeColor(val)
62
+ },
63
+ strokeOpacity (val) {
64
+ this.originInstance.setStrokeOpacity(val)
65
+ },
66
+ strokeWeight (val) {
67
+ this.originInstance.setStrokeWeight(val)
68
+ },
69
+ strokeStyle (val) {
70
+ this.originInstance.setStrokeStyle(val)
71
+ },
72
+ editing (val) {
73
+ val ? this.originInstance.enableEditing() : this.originInstance.disableEditing()
74
+ },
75
+ massClear (val) {
76
+ val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear()
77
+ },
78
+ clicking (val) {
79
+ this.reload()
80
+ }
81
+ },
82
+ methods: {
83
+ load () {
84
+ const {BMap, map, points, strokeColor, strokeWeight, strokeOpacity, strokeStyle, editing, massClear, clicking} = this
85
+ const overlay = new CurveLine(points.map(item => createPoint(BMap, item)), {
86
+ strokeColor,
87
+ strokeWeight,
88
+ strokeOpacity,
89
+ strokeStyle,
90
+ // enableEditing: editing,
91
+ enableMassClear: massClear,
92
+ enableClicking: clicking
93
+ })
94
+ editing ? overlay.enableEditing() : overlay.disableEditing()
95
+ this.originInstance = overlay
96
+ map.addOverlay(overlay)
97
+ bindEvents.call(this, overlay, eventList)
98
+ }
99
+ }
100
+ }
101
+ </script>
@@ -0,0 +1,78 @@
1
+ <script>
2
+ import commonMixin from '../base/mixins/common.js'
3
+ import Heatmap from 'bmaplib.heatmap'
4
+
5
+ export default {
6
+ name: 'bml-heatmap',
7
+ render () {},
8
+ mixins: [commonMixin('overlay')],
9
+ props: {
10
+ data: {
11
+ type: Array,
12
+ default: Array
13
+ },
14
+ max: {
15
+ type: Number
16
+ },
17
+ radius: {
18
+ type: Number
19
+ },
20
+ gradient: {
21
+ type: Object
22
+ },
23
+ opacity: {
24
+ type: Number
25
+ }
26
+ },
27
+ watch: {
28
+ data: {
29
+ handler () {
30
+ this.reload()
31
+ },
32
+ deep: true
33
+ },
34
+ max () {
35
+ this.reload()
36
+ },
37
+ radius (val) {
38
+ const {originInstance, opacity, gradient} = this
39
+ originInstance.setOptions({
40
+ radius: val,
41
+ opacity,
42
+ gradient
43
+ })
44
+ },
45
+ gradient: {
46
+ handler (val) {
47
+ const {originInstance, radius, opacity} = this
48
+ originInstance.setOptions({
49
+ radius,
50
+ opacity,
51
+ gradient: val
52
+ })
53
+ },
54
+ deep: true
55
+ },
56
+ opacity (val) {
57
+ const {originInstance, radius, gradient} = this
58
+ originInstance.setOptions({
59
+ radius,
60
+ opacity: val,
61
+ gradient
62
+ })
63
+ }
64
+ },
65
+ methods: {
66
+ load () {
67
+ const {map, data, max, radius, opacity, gradient} = this
68
+ const overlay = this.originInstance = new Heatmap({
69
+ radius,
70
+ opacity,
71
+ gradient
72
+ })
73
+ map.addOverlay(overlay)
74
+ overlay.setDataSet({data, max})
75
+ }
76
+ }
77
+ }
78
+ </script>
@@ -0,0 +1,125 @@
1
+ <script>
2
+ /*eslint-disable*/
3
+ import commonMixin from '../base/mixins/common.js'
4
+ import {createIcon} from '../base/factory.js'
5
+ import Lushu from 'bmaplib.lushu'
6
+
7
+ export default {
8
+ name: 'bm-lushu',
9
+ render (h) {},
10
+ mixins: [commonMixin('lushu')],
11
+ props: {
12
+ path: {
13
+ type: Array,
14
+ default: []
15
+ },
16
+ landmarkPois: {
17
+ type: Array,
18
+ default () {
19
+ return []
20
+ }
21
+ },
22
+ icon: {
23
+ type: Object
24
+ },
25
+ speed: {
26
+ type: Number,
27
+ default: 4000
28
+ },
29
+ content: {
30
+ type: String,
31
+ default: ''
32
+ },
33
+ autoView: {
34
+ type: Boolean,
35
+ default: false
36
+ },
37
+ rotation: {
38
+ type: Boolean,
39
+ default: false
40
+ },
41
+ infoWindow: {
42
+ type: Boolean,
43
+ default: true
44
+ },
45
+ play: {
46
+ type: Boolean,
47
+ default: true
48
+ }
49
+ },
50
+ watch: {
51
+ path: {
52
+ handler (val) {
53
+ this.reload()
54
+ },
55
+ deep: true
56
+ },
57
+ landmarkPois: {
58
+ handler (val) {
59
+ this.reload()
60
+ },
61
+ deep: true
62
+ },
63
+ icon: {
64
+ handler (val) {
65
+ const {originInstance, content} = this
66
+ const newMarker = createIcon(BMap, val)
67
+ originInstance._opts.icon = newMarker
68
+ originInstance._marker = newMarker
69
+ },
70
+ deep: true
71
+ },
72
+ speed (val) {
73
+ const {originInstance, content} = this
74
+ originInstance._opts.speed = val
75
+ },
76
+ content (val) {
77
+ const {originInstance, infoWindow} = this
78
+ val && infoWindow ? originInstance.showInfoWindow() : originInstance.hideInfoWindow()
79
+ originInstance._opts.defaultContent = val
80
+ originInstance._overlay && originInstance._overlay.setHtml(val)
81
+ },
82
+ autoView (val) {
83
+ const {originInstance, content} = this
84
+ originInstance._opts.autoView = val
85
+ },
86
+ rotation (val) {
87
+ const {originInstance, content} = this
88
+ originInstance._opts.enableRotation = val
89
+ },
90
+ infoWindow (val) {
91
+ const {originInstance, content} = this
92
+ originInstance && val && content ? originInstance.showInfoWindow() : originInstance.hideInfoWindow()
93
+ },
94
+ play (val) {
95
+ const {originInstance} = this
96
+ val && originInstance ? originInstance.start() : !this._isEnd && originInstance.pause()
97
+ }
98
+ },
99
+ methods: {
100
+ load () {
101
+ const {BMap, map, path, landmarkPois, icon, speed, content, autoView, rotation, infoWindow, play} = this
102
+ const lushu = this.originInstance = new Lushu(map, path, {
103
+ enableRotation: rotation,
104
+ landmarkPois,
105
+ showInfoWindow: infoWindow,
106
+ defaultContent: content,
107
+ icon: icon && createIcon(BMap, icon),
108
+ speed,
109
+ autoView,
110
+ onstart: e => {
111
+ this._isEnd = false
112
+ this.$emit('start')
113
+ },
114
+ onstop: e => {
115
+ this._isEnd = true
116
+ this.$emit('stop')
117
+ },
118
+ onpause: e => this.$emit('pause')
119
+ })
120
+ play && path.length && lushu.start(this)
121
+ path.length && (content && infoWindow ? lushu.showInfoWindow() : lushu.hideInfoWindow())
122
+ }
123
+ }
124
+ }
125
+ </script>