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.
- package/LICENSE +21 -0
- package/README.md +95 -0
- package/README.zh.md +97 -0
- package/components/base/bindEvent.js +11 -0
- package/components/base/events.js +120 -0
- package/components/base/factory.js +63 -0
- package/components/base/mixins/abstract.js +13 -0
- package/components/base/mixins/common.js +81 -0
- package/components/base/util.js +6 -0
- package/components/context-menu/Item.vue +62 -0
- package/components/context-menu/Menu.vue +52 -0
- package/components/controls/CityList.vue +43 -0
- package/components/controls/Control.vue +37 -0
- package/components/controls/Copyright.vue +52 -0
- package/components/controls/Geolocation.vue +59 -0
- package/components/controls/MapType.vue +39 -0
- package/components/controls/Navigation.vue +55 -0
- package/components/controls/OverviewMap.vue +56 -0
- package/components/controls/Panorama.vue +29 -0
- package/components/controls/Scale.vue +36 -0
- package/components/extra/CurveLine.vue +101 -0
- package/components/extra/Heatmap.vue +78 -0
- package/components/extra/Lushu.vue +125 -0
- package/components/extra/MarkerClusterer.vue +93 -0
- package/components/index.js +98 -0
- package/components/layers/Tile.vue +53 -0
- package/components/layers/Traffic.vue +34 -0
- package/components/map/Map.vue +302 -0
- package/components/map/MapView.vue +9 -0
- package/components/others/AutoComplete.vue +70 -0
- package/components/others/Boundary.vue +60 -0
- package/components/overlays/Circle.vue +170 -0
- package/components/overlays/Ground.vue +65 -0
- package/components/overlays/Icon.vue +0 -0
- package/components/overlays/InfoWindow.vue +137 -0
- package/components/overlays/Label.vue +99 -0
- package/components/overlays/Marker.vue +163 -0
- package/components/overlays/Overlay.vue +55 -0
- package/components/overlays/PointCollection.vue +76 -0
- package/components/overlays/Polygon.vue +105 -0
- package/components/overlays/Polyline.vue +107 -0
- package/components/overlays/Symblo.vue +0 -0
- package/components/search/Bus.vue +102 -0
- package/components/search/Driving.vue +177 -0
- package/components/search/LocalSearch.vue +152 -0
- package/components/search/Transit.vue +126 -0
- package/components/search/Walking.vue +115 -0
- package/index.js +1 -0
- package/package.json +104 -0
- package/types/auto-complete.d.ts +22 -0
- package/types/base/base-control.d.ts +14 -0
- package/types/base/common.d.ts +171 -0
- package/types/base/component.d.ts +5 -0
- package/types/boundary.d.ts +41 -0
- package/types/bus.d.ts +28 -0
- package/types/circle.d.ts +47 -0
- package/types/city-list.d.ts +3 -0
- package/types/control.d.ts +3 -0
- package/types/copyright.d.ts +7 -0
- package/types/curve-line.d.ts +37 -0
- package/types/driving.d.ts +48 -0
- package/types/geolocation.d.ts +18 -0
- package/types/ground.d.ts +25 -0
- package/types/heatmap.d.ts +29 -0
- package/types/index.d.ts +93 -0
- package/types/info-window.d.ts +52 -0
- package/types/item.d.ts +26 -0
- package/types/label.d.ts +36 -0
- package/types/local-search.d.ts +63 -0
- package/types/lushu.d.ts +54 -0
- package/types/map-type.d.ts +13 -0
- package/types/map-view.d.ts +4 -0
- package/types/map.d.ts +88 -0
- package/types/marker-clusterer.d.ts +26 -0
- package/types/marker.d.ts +79 -0
- package/types/menu.d.ts +8 -0
- package/types/navigation.d.ts +18 -0
- package/types/overlay.d.ts +17 -0
- package/types/overview-map.d.ts +14 -0
- package/types/panorama.d.ts +3 -0
- package/types/point-collection.d.ts +27 -0
- package/types/polygon.d.ts +47 -0
- package/types/polyline.d.ts +43 -0
- package/types/scale.d.ts +3 -0
- package/types/tile.d.ts +22 -0
- package/types/traffic.d.ts +9 -0
- package/types/transit.d.ts +40 -0
- package/types/tsconfig.json +17 -0
- package/types/walking.d.ts +36 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="paths.length">
|
|
3
|
+
<bm-polygon
|
|
4
|
+
v-for="(path, index) of paths"
|
|
5
|
+
:key="index"
|
|
6
|
+
:path="path"
|
|
7
|
+
:stroke-color="strokeColor"
|
|
8
|
+
:stroke-weight="strokeWeight"
|
|
9
|
+
:stroke-opacity="strokeOpacity"
|
|
10
|
+
:stroke-style="strokeStyle"
|
|
11
|
+
:fill-opacity="fillOpacity"
|
|
12
|
+
:fill-color="fillColor"
|
|
13
|
+
:mass-clear="massClear"
|
|
14
|
+
:clicking="clicking"
|
|
15
|
+
@click="$emit('click', $event)"
|
|
16
|
+
@dblclick="$emit('dblclick', $event)"
|
|
17
|
+
@mousedown="$emit('mousedown', $event)"
|
|
18
|
+
@mouseup="$emit('mouseup', $event)"
|
|
19
|
+
@mouseout="$emit('mouseout', $event)"
|
|
20
|
+
@mouseover="$emit('mouseover', $event)"
|
|
21
|
+
@remove="$emit('remove', $event)"
|
|
22
|
+
/>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
import BmPolygon from '../overlays/Polygon.vue'
|
|
28
|
+
import commonMixin from '../base/mixins/common.js'
|
|
29
|
+
// import abstractMixin from '../base/mixins/abstract.js'
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
mixins: [
|
|
33
|
+
commonMixin('abstract')
|
|
34
|
+
],
|
|
35
|
+
props: ['name', 'strokeColor', 'strokeWeight', 'strokeOpacity', 'strokeStyle', 'fillColor', 'fillOpacity', 'massClear', 'clicking'],
|
|
36
|
+
data () {
|
|
37
|
+
return {
|
|
38
|
+
paths: []
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
components: {
|
|
42
|
+
BmPolygon
|
|
43
|
+
},
|
|
44
|
+
watch: {
|
|
45
|
+
name () {
|
|
46
|
+
this.reload()
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
methods: {
|
|
50
|
+
load () {
|
|
51
|
+
const {BMap, name} = this
|
|
52
|
+
const bd = new BMap.Boundary()
|
|
53
|
+
bd.get(name, data => {
|
|
54
|
+
this.paths = data.boundaries.map(boundary => (boundary || []).split(';')
|
|
55
|
+
.map(point => (([lng, lat]) => ({lng, lat}))(point.split(',').map(p => +p))))
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
@@ -0,0 +1,170 @@
|
|
|
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-circle',
|
|
8
|
+
render () {},
|
|
9
|
+
mixins: [commonMixin('overlay')],
|
|
10
|
+
props: {
|
|
11
|
+
center: {
|
|
12
|
+
},
|
|
13
|
+
radius: {
|
|
14
|
+
},
|
|
15
|
+
strokeColor: {
|
|
16
|
+
type: String
|
|
17
|
+
},
|
|
18
|
+
strokeWeight: {
|
|
19
|
+
type: Number
|
|
20
|
+
},
|
|
21
|
+
strokeOpacity: {
|
|
22
|
+
type: Number
|
|
23
|
+
},
|
|
24
|
+
strokeStyle: {
|
|
25
|
+
type: String
|
|
26
|
+
},
|
|
27
|
+
fillColor: {
|
|
28
|
+
type: String
|
|
29
|
+
},
|
|
30
|
+
fillOpacity: {
|
|
31
|
+
type: Number
|
|
32
|
+
},
|
|
33
|
+
massClear: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: true
|
|
36
|
+
},
|
|
37
|
+
clicking: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: true
|
|
40
|
+
},
|
|
41
|
+
editing: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
watch: {
|
|
47
|
+
'center.lng' (val, oldVal) {
|
|
48
|
+
const {BMap, originInstance, isEditing, disableEditing, enableEditing, center, editing} = this
|
|
49
|
+
if (!isEditing) {
|
|
50
|
+
disableEditing()
|
|
51
|
+
const lng = val
|
|
52
|
+
if (val.toString() !== oldVal.toString() && lng >= -180 && lng <= 180) {
|
|
53
|
+
originInstance.setCenter(createPoint(BMap, {lng, lat: center.lat}))
|
|
54
|
+
}
|
|
55
|
+
editing && enableEditing()
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
'center.lat' (val, oldVal) {
|
|
59
|
+
const {BMap, originInstance, isEditing, disableEditing, enableEditing, center, editing} = this
|
|
60
|
+
if (!isEditing) {
|
|
61
|
+
disableEditing()
|
|
62
|
+
const lat = val
|
|
63
|
+
if (val.toString() !== oldVal.toString() && lat >= -74 && lat <= 74) {
|
|
64
|
+
originInstance.setCenter(createPoint(BMap, {lng: center.lng, lat}))
|
|
65
|
+
}
|
|
66
|
+
editing && enableEditing()
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
radius (val, oldVal) {
|
|
70
|
+
const {originInstance, isEditing, disableEditing, enableEditing, editing} = this
|
|
71
|
+
if (!isEditing) {
|
|
72
|
+
disableEditing()
|
|
73
|
+
originInstance.setRadius(val)
|
|
74
|
+
editing && enableEditing()
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
strokeColor (val) {
|
|
78
|
+
this.originInstance.setStrokeColor(val)
|
|
79
|
+
},
|
|
80
|
+
strokeOpacity (val) {
|
|
81
|
+
this.originInstance.setStrokeOpacity(val)
|
|
82
|
+
},
|
|
83
|
+
strokeWeight (val) {
|
|
84
|
+
this.originInstance.setStrokeWeight(val)
|
|
85
|
+
},
|
|
86
|
+
strokeStyle (val) {
|
|
87
|
+
this.originInstance.setStrokeStyle(val)
|
|
88
|
+
},
|
|
89
|
+
fillColor (val) {
|
|
90
|
+
this.originInstance.setFillColor(val)
|
|
91
|
+
},
|
|
92
|
+
fillOpacity (val) {
|
|
93
|
+
this.originInstance.setFillOpacity(val)
|
|
94
|
+
},
|
|
95
|
+
editing (val) {
|
|
96
|
+
val ? this.enableEditing() : this.disableEditing()
|
|
97
|
+
},
|
|
98
|
+
massClear (val) {
|
|
99
|
+
val ? this.originInstance.enableMassClear() : this.originInstance.disableMassClear()
|
|
100
|
+
},
|
|
101
|
+
clicking (val) {
|
|
102
|
+
this.reload()
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
methods: {
|
|
106
|
+
dragStartHandler () {
|
|
107
|
+
this.isEditing = true
|
|
108
|
+
},
|
|
109
|
+
dragEndHandler () {
|
|
110
|
+
this.isEditing = false
|
|
111
|
+
this.bindEditingNodeEvents()
|
|
112
|
+
},
|
|
113
|
+
bindEditingNodeEvents () {
|
|
114
|
+
const {originInstance, editingKey, dragStartHandler, dragEndHandler} = this
|
|
115
|
+
originInstance[editingKey].forEach($node => {
|
|
116
|
+
$node.addEventListener('dragstart', dragStartHandler)
|
|
117
|
+
$node.addEventListener('dragend', dragEndHandler)
|
|
118
|
+
})
|
|
119
|
+
},
|
|
120
|
+
enableEditing () {
|
|
121
|
+
const {originInstance, bindEditingNodeEvents} = this
|
|
122
|
+
originInstance.enableEditing()
|
|
123
|
+
bindEditingNodeEvents()
|
|
124
|
+
},
|
|
125
|
+
disableEditing () {
|
|
126
|
+
const {originInstance} = this
|
|
127
|
+
originInstance.disableEditing()
|
|
128
|
+
},
|
|
129
|
+
getEditingKey (overlay) {
|
|
130
|
+
const stack = []
|
|
131
|
+
overlay.enableEditing()
|
|
132
|
+
setTimeout(() => {
|
|
133
|
+
for (const key in overlay) {
|
|
134
|
+
if (overlay[key] && overlay[key].length === 2) {
|
|
135
|
+
stack.push(key)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
overlay.disableEditing()
|
|
139
|
+
for (const key in overlay) {
|
|
140
|
+
if (overlay[key] && overlay[key].length === 0 && ~stack.indexOf(key)) {
|
|
141
|
+
this.editingKey = key
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}, 0)
|
|
145
|
+
},
|
|
146
|
+
load () {
|
|
147
|
+
const {BMap, map, center, radius, strokeColor, strokeWeight, strokeOpacity, strokeStyle, fillColor, fillOpacity, editing, massClear, clicking, enableEditing, disableEditing, getEditingKey, editingKey} = this
|
|
148
|
+
const overlay = new BMap.Circle(createPoint(BMap, {lng: center.lng, lat: center.lat}), radius, {
|
|
149
|
+
strokeColor,
|
|
150
|
+
strokeWeight,
|
|
151
|
+
strokeOpacity,
|
|
152
|
+
strokeStyle,
|
|
153
|
+
fillColor,
|
|
154
|
+
fillOpacity,
|
|
155
|
+
// enableEditing: editing,
|
|
156
|
+
enableMassClear: massClear,
|
|
157
|
+
enableClicking: clicking
|
|
158
|
+
})
|
|
159
|
+
this.originInstance = overlay
|
|
160
|
+
map.addOverlay(overlay)
|
|
161
|
+
bindEvents.call(this, overlay)
|
|
162
|
+
// 解决圆形组件无法双向绑定的问题
|
|
163
|
+
!editingKey && getEditingKey(overlay)
|
|
164
|
+
setTimeout(() => {
|
|
165
|
+
editing ? enableEditing() : disableEditing()
|
|
166
|
+
}, 0)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
</script>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import commonMixin from '../base/mixins/common.js'
|
|
3
|
+
import bindEvents from '../base/bindEvent.js'
|
|
4
|
+
import {createBounds} from '../base/factory.js'
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
name: 'bm-ground',
|
|
8
|
+
render () {},
|
|
9
|
+
mixins: [commonMixin('overlay')],
|
|
10
|
+
props: {
|
|
11
|
+
bounds: {
|
|
12
|
+
type: Object
|
|
13
|
+
},
|
|
14
|
+
opacity: {
|
|
15
|
+
type: Number
|
|
16
|
+
},
|
|
17
|
+
imageURL: {
|
|
18
|
+
type: String
|
|
19
|
+
},
|
|
20
|
+
displayOnMinLevel: {
|
|
21
|
+
type: Number
|
|
22
|
+
},
|
|
23
|
+
displayOnMaxLevel: {
|
|
24
|
+
type: Number
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
watch: {
|
|
28
|
+
bounds: {
|
|
29
|
+
handler (val) {
|
|
30
|
+
const {BMap} = this
|
|
31
|
+
this.originInstance.setBounds(createBounds(BMap, val))
|
|
32
|
+
},
|
|
33
|
+
deep: true
|
|
34
|
+
},
|
|
35
|
+
opacity (val) {
|
|
36
|
+
this.originInstance.setOpacity(val)
|
|
37
|
+
},
|
|
38
|
+
imageURL (val) {
|
|
39
|
+
this.originInstance.setImageURL(val)
|
|
40
|
+
},
|
|
41
|
+
displayOnMinLevel (val) {
|
|
42
|
+
this.originInstance.setDisplayOnMinLevel(val)
|
|
43
|
+
},
|
|
44
|
+
displayOnMaxLevel (val) {
|
|
45
|
+
this.originInstance.setDisplayOnMaxLevel(val)
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
methods: {
|
|
49
|
+
load () {
|
|
50
|
+
const {BMap, map, bounds, opacity, imageURL, displayOnMinLevel, displayOnMaxLevel} = this
|
|
51
|
+
const overlay = new BMap.GroundOverlay(bounds && createBounds(BMap, bounds), {
|
|
52
|
+
opacity,
|
|
53
|
+
imageURL,
|
|
54
|
+
displayOnMaxLevel,
|
|
55
|
+
displayOnMinLevel
|
|
56
|
+
})
|
|
57
|
+
// option 中配置 https 协议地址无法加载
|
|
58
|
+
overlay.setImageURL(imageURL)
|
|
59
|
+
this.originInstance = overlay
|
|
60
|
+
bindEvents.call(this, overlay)
|
|
61
|
+
map.addOverlay(overlay)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
</script>
|
|
File without changes
|
|
@@ -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>
|