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,6 @@
1
+ import {createPoint} from './factory'
2
+
3
+ export const isPoint = obj => obj.lng && obj.lat
4
+ export const checkType = val => Object.prototype.toString.call(val).slice(8, -1)
5
+
6
+ export const getPosition = (BMap, point) => isPoint(point) ? createPoint(BMap, point) : point
@@ -0,0 +1,62 @@
1
+ <template>
2
+ <span>
3
+ <slot></slot>
4
+ </span>
5
+ </template>
6
+ <script>
7
+ export default {
8
+ name: 'bm-context-menu-item',
9
+ props: {
10
+ callback: {
11
+ type: Function,
12
+ default: function () {}
13
+ },
14
+ text: {
15
+ type: String
16
+ },
17
+ iconUrl: {
18
+ type: String
19
+ },
20
+ id: {
21
+ type: String
22
+ },
23
+ disabled: {
24
+ type: Boolean
25
+ },
26
+ seperator: {
27
+ type: Boolean
28
+ }
29
+ },
30
+ methods: {
31
+ reload () {
32
+ this.$parent.map && this.$parent.load()
33
+ }
34
+ },
35
+ watch: {
36
+ text () {
37
+ this.reload()
38
+ },
39
+ iconUrl () {
40
+ this.reload()
41
+ },
42
+ id () {
43
+ this.reload()
44
+ },
45
+ disabled () {
46
+ this.reload()
47
+ },
48
+ iseperator () {
49
+ this.reload()
50
+ },
51
+ callback () {
52
+ this.reload()
53
+ }
54
+ },
55
+ destroyed () {
56
+ this.reload()
57
+ },
58
+ mounted () {
59
+ this.reload()
60
+ }
61
+ }
62
+ </script>
@@ -0,0 +1,52 @@
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-context-menu',
12
+ props: {
13
+ width: {
14
+ type: Number
15
+ }
16
+ },
17
+ mixins: [commonMixin('contextMenu')],
18
+ methods: {
19
+ load () {
20
+ const {width, BMap, map, $parent} = this
21
+ const parent = this.parent = $parent.originInstance || map
22
+ if (this.originInstance) {
23
+ parent.removeContextMenu(this.originInstance)
24
+ }
25
+ const menu = this.originInstance = new BMap.ContextMenu()
26
+ for (const item of this.$children) {
27
+ if (item.seperator) {
28
+ menu.addSeparator()
29
+ continue
30
+ }
31
+ const menuItem = new BMap.MenuItem(item.text, function (point, pixel) {
32
+ item.callback({
33
+ point,
34
+ pixel,
35
+ BMap,
36
+ map,
37
+ target: parent
38
+ })
39
+ }, {
40
+ width,
41
+ id: item.id,
42
+ iconUrl: item.iconUrl
43
+ })
44
+ item.disabled ? menuItem.disable() : menuItem.enable()
45
+ item.originInstance = menuItem
46
+ menu.addItem(menuItem)
47
+ }
48
+ parent.addContextMenu(menu)
49
+ }
50
+ }
51
+ }
52
+ </script>
@@ -0,0 +1,43 @@
1
+ <script>
2
+ import commonMixin from '../base/mixins/common.js'
3
+ import {createSize} from '../base/factory.js'
4
+
5
+ export default {
6
+ name: 'bm-city-list',
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
+ const self = this
29
+ this.originInstance = new BMap.CityListControl({
30
+ anchor: global[anchor],
31
+ offset: offset && createSize(BMap, offset),
32
+ onChangeBefore () {
33
+ self.$emit('changeBefore')
34
+ },
35
+ onChangeAfter () {
36
+ self.$emit('changeAfter')
37
+ }
38
+ })
39
+ map.addControl(this.originInstance)
40
+ }
41
+ }
42
+ }
43
+ </script>
@@ -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>