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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 马金花儿
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # VUE BAIDU MAP (API v3)
2
+
3
+ > **⚠️ Special Instruction**
4
+ >
5
+ > **The current package is copied from the Vue-Baidu-Map of Dafrok. Since the original author has not maintained the Vue-Baidu-Map package, I copied it for personal use and changed the BAIDU Map API to 3.0.**
6
+ >
7
+ > - Original repository: [https://github.com/Dafrok/vue-baidu-map](https://github.com/Dafrok/vue-baidu-map)
8
+ > - This is a maintained fork with API 3.0 support
9
+
10
+ <p align="center">
11
+ <img src="https://dafrok.github.io/vue-baidu-map/favicon.png" width="200px">
12
+ </p>
13
+ <p align="center">Baidu Map components for Vue 2.x (API v3)</p>
14
+
15
+ [![npm](https://img.shields.io/npm/v/vue-baidu-map.svg)]()
16
+ [![Travis](https://img.shields.io/travis/Dafrok/vue-baidu-map.svg)]()
17
+ [![Package Quality](http://npm.packagequality.com/shield/vue-baidu-map.svg)](http://packagequality.com/#?package=vue-baidu-map)
18
+ [![npm](https://img.shields.io/npm/dm/vue-baidu-map.svg)]()
19
+ [![license](https://img.shields.io/github/license/dafrok/vue-baidu-map.svg)]()
20
+
21
+ ## Languages
22
+
23
+ - [中文](https://github.com/Dafrok/vue-baidu-map/blob/master/README.zh.md)
24
+ - [English](https://github.com/Dafrok/vue-baidu-map/blob/master/README.md)
25
+
26
+ ## Documentation
27
+
28
+ [https://dafrok.github.io/vue-baidu-map](https://dafrok.github.io/vue-baidu-map)
29
+
30
+ ## Get Start
31
+
32
+ ### Installation
33
+
34
+ ```bash
35
+ npm i --save vue-baidu-map-api-v3
36
+ ```
37
+
38
+ ### Initialization
39
+
40
+ ```javascript
41
+ import Vue from 'vue'
42
+ import BaiduMap from 'vue-baidu-map-api-v3'
43
+
44
+ Vue.use(BaiduMap, {
45
+ /* Visit http://lbsyun.baidu.com/apiconsole/key for details about app key. */
46
+ ak: 'YOUR_APP_KEY',
47
+ /* Optional: specify Baidu Map API version (default: '3.0') */
48
+ apiV: '3.0'
49
+ })
50
+ ```
51
+
52
+ **Global Configuration Options:**
53
+ - `ak` (required): Your Baidu Map API key
54
+ - `apiV` (optional): Baidu Map API version (default: '3.0')
55
+
56
+ ### Usage
57
+
58
+ #### Basic Usage
59
+
60
+ ```vue
61
+ <template>
62
+ <baidu-map class="map">
63
+ </baidu-map>
64
+ </template>
65
+
66
+ <style>
67
+ /* The container of BaiduMap must be set width & height. */
68
+ .map {
69
+ width: 100%;
70
+ height: 300px;
71
+ }
72
+ </style>
73
+ ```
74
+
75
+ #### Override API Version in Component
76
+
77
+ You can also specify the `apiV` prop directly on the map component to override the global configuration:
78
+
79
+ ```vue
80
+ <template>
81
+ <baidu-map class="map" ak="YOUR_APP_KEY" api-v="3.0">
82
+ </baidu-map>
83
+ </template>
84
+ ```
85
+
86
+ ## Contributing
87
+
88
+ [Contributing Guide](https://github.com/Dafrok/vue-baidu-map/blob/master/CONTRIBUTING.md)
89
+
90
+
91
+ ## License
92
+
93
+ [MIT License](https://opensource.org/licenses/MIT)
94
+
95
+ Copyright (c) 2016-present, Dafrok <o.o@mug.dog>
package/README.zh.md ADDED
@@ -0,0 +1,97 @@
1
+ # VUE BAIDU MAP (API v3)
2
+
3
+ > **⚠️ 特殊说明**
4
+ >
5
+ > **本包是从 Dafrok 的 Vue-Baidu-Map 项目复制而来。由于原作者已不再维护 vue-baidu-map 包,我复制它用于个人使用并将百度地图 API 更新为 3.0 版本。**
6
+ >
7
+ > - 原项目地址: [https://github.com/Dafrok/vue-baidu-map](https://github.com/Dafrok/vue-baidu-map)
8
+ > - 这是一个支持 API 3.0 的维护版本
9
+
10
+ <p align="center">
11
+ <img src="https://dafrok.github.io/vue-baidu-map/favicon.png" width="200px">
12
+ </p>
13
+ <p align="center">基于 VUE 2.x 的百度地图组件 (API v3)</p>
14
+
15
+ [![npm](https://img.shields.io/npm/v/vue-baidu-map.svg)]()
16
+ [![Travis](https://img.shields.io/travis/Dafrok/vue-baidu-map.svg)]()
17
+ [![Package Quality](http://npm.packagequality.com/shield/vue-baidu-map.svg)](http://packagequality.com/#?package=vue-baidu-map)
18
+ [![npm](https://img.shields.io/npm/dm/vue-baidu-map.svg)]()
19
+ [![license](https://img.shields.io/github/license/dafrok/vue-baidu-map.svg)]()
20
+
21
+ ## 语言
22
+
23
+ - [中文](https://github.com/Dafrok/vue-baidu-map/blob/master/README.zh.md)
24
+ - [English](https://github.com/Dafrok/vue-baidu-map/blob/master/README.md)
25
+
26
+ ## 文档
27
+
28
+ [https://dafrok.github.io/vue-baidu-map](https://dafrok.github.io/vue-baidu-map)
29
+
30
+ ## 开始
31
+
32
+ ### 安装
33
+
34
+ ```bash
35
+ npm i --save vue-baidu-map-api-v3
36
+ ```
37
+
38
+ ### 初始化
39
+
40
+ ```javascript
41
+ import Vue from 'vue'
42
+ import BaiduMap from 'vue-baidu-map-api-v3'
43
+
44
+ Vue.use(BaiduMap, {
45
+ // ak 是在百度地图开发者平台申请的密钥 详见 http://lbsyun.baidu.com/apiconsole/key */
46
+ ak: 'YOUR_APP_KEY',
47
+ // 可选:指定百度地图 API 版本(默认:'3.0')
48
+ apiV: '3.0'
49
+ })
50
+ ```
51
+
52
+ **全局配置选项:**
53
+ - `ak`(必需):百度地图 API 密钥
54
+ - `apiV`(可选):百度地图 API 版本(默认:'3.0')
55
+
56
+ ### 使用
57
+
58
+ #### 基础用法
59
+
60
+ ```vue
61
+ <template>
62
+ <baidu-map class="map">
63
+ </baidu-map>
64
+ </template>
65
+
66
+ <style>
67
+ /* 地图容器必须设置宽和高属性 */
68
+ .map {
69
+ width: 400px;
70
+ height: 300px;
71
+ }
72
+ </style>
73
+ ```
74
+
75
+ #### 在组件中覆盖 API 版本
76
+
77
+ 你也可以在地图组件上直接指定 `apiV` 属性来覆盖全局配置:
78
+
79
+ ```vue
80
+ <template>
81
+ <baidu-map class="map" ak="YOUR_APP_KEY" api-v="3.0">
82
+ </baidu-map>
83
+ </template>
84
+ ```
85
+
86
+ ## 贡献
87
+
88
+ [贡献指南](https://github.com/Dafrok/vue-baidu-map/blob/master/CONTRIBUTING.md)
89
+
90
+
91
+ ## 协议
92
+
93
+ [MIT 许可证](https://opensource.org/licenses/MIT)
94
+
95
+ 版权所有 (c) 2016至今, Dafrok <o.o@mug.dog>
96
+
97
+
@@ -0,0 +1,11 @@
1
+ import events from './events.js'
2
+
3
+ export default function (instance, eventList) {
4
+ const ev = eventList || events[this.$options.name]
5
+ ev && ev.forEach(event => {
6
+ const hasOn = event.slice(0, 2) === 'on'
7
+ const eventName = hasOn ? event.slice(2) : event
8
+ const listener = this.$listeners[eventName]
9
+ listener && instance.addEventListener(event, listener.fns)
10
+ })
11
+ }
@@ -0,0 +1,120 @@
1
+ export default {
2
+ 'bm-map': [
3
+ 'click',
4
+ 'dblclick',
5
+ 'rightclick',
6
+ 'rightdblclick',
7
+ 'maptypechange',
8
+ 'mousemove',
9
+ 'mouseover',
10
+ 'mouseout',
11
+ 'movestart',
12
+ 'moving',
13
+ 'moveend',
14
+ 'zoomstart',
15
+ 'zoomend',
16
+ 'addoverlay',
17
+ 'addcontrol',
18
+ 'removecontrol',
19
+ 'removeoverlay',
20
+ 'clearoverlays',
21
+ 'dragstart',
22
+ 'dragging',
23
+ 'dragend',
24
+ 'addtilelayer',
25
+ 'removetilelayer',
26
+ 'load',
27
+ 'resize',
28
+ 'hotspotclick',
29
+ 'hotspotover',
30
+ 'hotspotout',
31
+ 'tilesloaded',
32
+ 'touchstart',
33
+ 'touchmove',
34
+ 'touchend',
35
+ 'longpress'
36
+ ],
37
+ 'bm-geolocation': [
38
+ 'locationSuccess',
39
+ 'locationError'
40
+ ],
41
+ 'bm-overview-map': [
42
+ 'viewchanged',
43
+ 'viewchanging'
44
+ ],
45
+ 'bm-marker': [
46
+ 'click',
47
+ 'dblclick',
48
+ 'mousedown',
49
+ 'mouseup',
50
+ 'mouseout',
51
+ 'mouseover',
52
+ 'remove',
53
+ 'infowindowclose',
54
+ 'infowindowopen',
55
+ 'dragstart',
56
+ 'dragging',
57
+ 'dragend',
58
+ 'rightclick'
59
+ ],
60
+ 'bm-polyline': [
61
+ 'click',
62
+ 'dblclick',
63
+ 'mousedown',
64
+ 'mouseup',
65
+ 'mouseout',
66
+ 'mouseover',
67
+ 'remove',
68
+ 'lineupdate'
69
+ ],
70
+ 'bm-polygon': [
71
+ 'click',
72
+ 'dblclick',
73
+ 'mousedown',
74
+ 'mouseup',
75
+ 'mouseout',
76
+ 'mouseover',
77
+ 'remove',
78
+ 'lineupdate'
79
+ ],
80
+ 'bm-circle': [
81
+ 'click',
82
+ 'dblclick',
83
+ 'mousedown',
84
+ 'mouseup',
85
+ 'mouseout',
86
+ 'mouseover',
87
+ 'remove',
88
+ 'lineupdate'
89
+ ],
90
+ 'bm-label': [
91
+ 'click',
92
+ 'dblclick',
93
+ 'mousedown',
94
+ 'mouseup',
95
+ 'mouseout',
96
+ 'mouseover',
97
+ 'remove',
98
+ 'rightclick'
99
+ ],
100
+ 'bm-info-window': [
101
+ 'close',
102
+ 'open',
103
+ 'maximize',
104
+ 'restore',
105
+ 'clickclose'
106
+ ],
107
+ 'bm-ground': [
108
+ 'click',
109
+ 'dblclick'
110
+ ],
111
+ 'bm-autocomplete': [
112
+ 'onconfirm',
113
+ 'onhighlight'
114
+ ],
115
+ 'bm-point-collection': [
116
+ 'click',
117
+ 'mouseover',
118
+ 'mouseout'
119
+ ]
120
+ }
@@ -0,0 +1,63 @@
1
+ export function createPoint (BMap, options = {}) {
2
+ const {lng, lat} = options
3
+ return new BMap.Point(lng, lat)
4
+ }
5
+
6
+ export function createPixel (BMap, options = {}) {
7
+ const {x, y} = options
8
+ return new BMap.Pixel(x, y)
9
+ }
10
+
11
+ export function createBounds (BMap, options = {}) {
12
+ const {sw, ne} = options
13
+ return new BMap.Bounds(createPoint(BMap, sw), createPoint(BMap, ne))
14
+ }
15
+
16
+ export function createSize (BMap, options = {}) {
17
+ const {width, height} = options
18
+ return new BMap.Size(width, height)
19
+ }
20
+
21
+ export function createIcon (BMap, options = {}) {
22
+ const {url, size, opts = {}} = options
23
+ return new BMap.Icon(url, createSize(BMap, size), {
24
+ anchor: opts.anchor && createSize(BMap, opts.anchor),
25
+ imageSize: opts.imageSize && createSize(BMap, opts.imageSize),
26
+ imageOffset: opts.imageOffset && createSize(BMap, opts.imageOffset),
27
+ infoWindowAnchor: opts.infoWindowAnchor && createSize(BMap, opts.infoWindowAnchor),
28
+ printImageUrl: opts.printImageUrl
29
+ })
30
+ }
31
+
32
+ export function createLabel (BMap, options = {}) {
33
+ const {content, opts} = options
34
+ return new BMap.Label(content, {
35
+ offset: opts.offset && createSize(BMap, opts.offset),
36
+ position: opts.position && createPoint(BMap, opts.position),
37
+ enableMassClear: opts.enableMassClear
38
+ })
39
+ }
40
+
41
+ export function createSymbol (BMap, options = {}) {
42
+ const {path, opts} = options
43
+ return new BMap.Symbol(global[path] || path, {
44
+ anchor: opts.anchor && createSize(BMap, opts.anchor),
45
+ fillColor: opts.fillColor,
46
+ fillOpacity: opts.fillOpacity,
47
+ scale: opts.scale,
48
+ rotation: opts.rotation,
49
+ strokeColor: opts.strokeColor,
50
+ strokeOpacity: opts.strokeOpacity,
51
+ strokeWeight: opts.strokeWeight
52
+ })
53
+ }
54
+
55
+ export function createIconSequence (BMap, options = {}) {
56
+ const {symbol, offset, repeat, fixedRotation} = options
57
+ return new BMap.IconSequence(
58
+ symbol && createSymbol(BMap, symbol),
59
+ offset,
60
+ repeat,
61
+ fixedRotation
62
+ )
63
+ }
@@ -0,0 +1,13 @@
1
+ class Mixin {
2
+ constructor ({component, props, events, extraProps, exceptProps}) {
3
+ this.render = function (h) {
4
+ return h(component, {
5
+ props: props.reduce((obj, key) => Object.assign(obj, {[key]: this[key]}), {}),
6
+ on: events.reduce((obj, key) => Object.assign(obj, {[key]: this.transmitEvent}), {})
7
+ })
8
+ }
9
+ this.props = [...extraProps, ...props.filter(prop => exceptProps.indexOf(prop))]
10
+ }
11
+ }
12
+
13
+ export default prop => new Mixin(prop)
@@ -0,0 +1,81 @@
1
+ const types = {
2
+ control: {
3
+ unload: 'removeControl'
4
+ },
5
+ layer: {
6
+ unload: 'removeTileLayer'
7
+ },
8
+ overlay: {
9
+ unload: 'removeOverlay'
10
+ },
11
+ contextMenu: {
12
+ unload: 'removeContextMenu'
13
+ }
14
+ }
15
+
16
+ const getParent = $component => ($component.abstract || $component.$el === $component.$children[0].$el) ? getParent($component.$parent) : $component
17
+
18
+ function destroyInstance () {
19
+ const {unload, renderByParent, $parent} = this
20
+ if (renderByParent) {
21
+ $parent.reload()
22
+ }
23
+ unload()
24
+ }
25
+
26
+ class Mixin {
27
+ constructor (prop) {
28
+ this.methods = {
29
+ ready () {
30
+ const $parent = getParent(this.$parent)
31
+ const BMap = this.BMap = $parent.BMap
32
+ const map = this.map = $parent.map
33
+ this.load()
34
+ this.$emit('ready', {
35
+ BMap,
36
+ map
37
+ })
38
+ },
39
+ transmitEvent (e) {
40
+ this.$emit(e.type.replace(/^on/, ''), e)
41
+ },
42
+ reload () {
43
+ this && this.BMap && this.$nextTick(() => {
44
+ this.unload()
45
+ this.$nextTick(this.load)
46
+ })
47
+ },
48
+ unload () {
49
+ const {map, originInstance} = this
50
+ try {
51
+ switch (prop.type) {
52
+ case 'search':
53
+ return originInstance.clearResults()
54
+ case 'autoComplete':
55
+ case 'lushu':
56
+ return originInstance.dispose()
57
+ case 'markerClusterer':
58
+ return originInstance.clearMarkers()
59
+ default:
60
+ map[types[prop.type].unload](originInstance)
61
+ }
62
+ } catch (e) {}
63
+ }
64
+ }
65
+ this.computed = {
66
+ renderByParent () {
67
+ return this.$parent.preventChildrenRender
68
+ }
69
+ }
70
+ this.mounted = function () {
71
+ const $parent = getParent(this.$parent)
72
+ const map = $parent.map
73
+ const {ready} = this
74
+ map ? ready() : $parent.$on('ready', ready)
75
+ }
76
+ this.destroyed = destroyInstance
77
+ this.beforeDestroy = destroyInstance
78
+ }
79
+ }
80
+
81
+ export default type => new Mixin({type})
@@ -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>