@sword916/vae-map-plus 1.0.0
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/README.md +3 -0
- package/build/index.mjs +113 -0
- package/examples/App.vue +18 -0
- package/examples/index.js +13 -0
- package/examples/router/index.js +35 -0
- package/examples/views/amap.vue +29 -0
- package/examples/views/amarker.vue +58 -0
- package/examples/views/buffer.vue +66 -0
- package/examples/views/cluster.vue +74 -0
- package/examples/views/cover.vue +85 -0
- package/examples/views/draw-line.vue +49 -0
- package/examples/views/draw.vue +54 -0
- package/examples/views/echarts.vue +142 -0
- package/examples/views/emarker.vue +39 -0
- package/examples/views/image.vue +182 -0
- package/examples/views/index.vue +61 -0
- package/examples/views/lrmap.vue +108 -0
- package/examples/views/map.vue +82 -0
- package/examples/views/measure.vue +86 -0
- package/examples/views/parts/popup.vue +39 -0
- package/examples/views/parts/tooltip.vue +39 -0
- package/examples/views/push-area.vue +52 -0
- package/examples/views/push-line.vue +84 -0
- package/examples/views/trace.vue +49 -0
- package/index.html +13 -0
- package/jsconfig.json +17 -0
- package/package.json +47 -0
- package/public/favicon.ico +0 -0
- package/public/images/game.png +0 -0
- package/public/images/grid.png +0 -0
- package/public/images/marker.png +0 -0
- package/public/index.html +30 -0
- package/src/components/resize-listener/component.jsx +30 -0
- package/src/components/resize-listener/index.js +3 -0
- package/src/composables/useAutoMessage.js +41 -0
- package/src/composables/useContextMenu.js +99 -0
- package/src/composables/useMapMeasure.js +191 -0
- package/src/composables/useResizeObserver.js +81 -0
- package/src/mixins/message.js +1 -0
- package/src/packages/index.js +16 -0
- package/src/packages/vae-amap/index.js +8 -0
- package/src/packages/vae-amap/style.less +9 -0
- package/src/packages/vae-amap/vae-amap.jsx +98 -0
- package/src/packages/vae-cloudmap/ctrl-context-menu/index.vue +74 -0
- package/src/packages/vae-cloudmap/ctrl-draw/index.vue +499 -0
- package/src/packages/vae-cloudmap/ctrl-draw-line/index.vue +161 -0
- package/src/packages/vae-cloudmap/index.js +57 -0
- package/src/packages/vae-cloudmap/scripts/L.MarkerCluster/index.js +2690 -0
- package/src/packages/vae-cloudmap/scripts/L.MarkerCluster/style.css +14 -0
- package/src/packages/vae-cloudmap/scripts/L.Vae.CRS/index.js +212 -0
- package/src/packages/vae-cloudmap/scripts/L.Vae.Client/index.js +780 -0
- package/src/packages/vae-cloudmap/scripts/Mixin.ContextMenu/index.js +101 -0
- package/src/packages/vae-cloudmap/style.less +163 -0
- package/src/packages/vae-cloudmap/vae-cloudmap.jsx +272 -0
- package/src/packages/vae-map/ctrl-context-menu/index.vue +74 -0
- package/src/packages/vae-map/ctrl-draw/index.vue +498 -0
- package/src/packages/vae-map/ctrl-draw-line/index.vue +128 -0
- package/src/packages/vae-map/index.js +59 -0
- package/src/packages/vae-map/scripts/L.MarkerCluster/index.js +2690 -0
- package/src/packages/vae-map/scripts/L.MarkerCluster/style.css +14 -0
- package/src/packages/vae-map/scripts/L.Vae.CRS/index.js +114 -0
- package/src/packages/vae-map/scripts/L.Vae.Client/index.js +548 -0
- package/src/packages/vae-map/scripts/Mixin.ContextMenu/index.js +1 -0
- package/src/packages/vae-map/style.less +161 -0
- package/src/packages/vae-map/vae-lrmap.jsx +237 -0
- package/src/packages/vae-map/vae-map.jsx +135 -0
- package/src/plugins/L.AnimatedMarker/index.js +158 -0
- package/src/plugins/L.EchartsLayer/index.js +339 -0
- package/src/plugins/L.ElasticMarker/index.js +162 -0
- package/src/plugins/L.FootageCalculator.Area/index.js +263 -0
- package/src/plugins/L.FootageCalculator.Line/index.js +273 -0
- package/src/plugins/L.GeoUtil/buffer.js +67 -0
- package/src/plugins/L.GeoUtil/index.js +284 -0
- package/src/plugins/L.Glyphicon/index.js +91 -0
- package/src/plugins/L.Glyphicon/style.less +37 -0
- package/src/plugins/L.MarkerClusterX/index.js +93 -0
- package/src/plugins/L.MarkerClusterX/style.less +162 -0
- package/src/plugins/L.SafeDivOverlay/index.js +55 -0
- package/src/plugins/L.TileLayer.ChinaProvider/index.js +108 -0
- package/src/plugins/L.VuePopup/index.js +67 -0
- package/src/plugins/L.VueTooltip/index.js +63 -0
- package/src/plugins/Mixin.Map.Measure/index.js +248 -0
- package/src/plugins/globals/index.js +7 -0
- package/src/utils/index.js +36 -0
- package/src/utils/resize-event.js +45 -0
- package/vite.config.mjs +25 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import buffer from './buffer'
|
|
2
|
+
|
|
3
|
+
const fns = {
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 角度转弧度
|
|
7
|
+
* @param {角度} angle
|
|
8
|
+
*/
|
|
9
|
+
angleToRad(angle) {
|
|
10
|
+
return angle * Math.PI / 180
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 弧度转角度
|
|
15
|
+
* @param {弧度} rad
|
|
16
|
+
*/
|
|
17
|
+
radToAngle(rad) {
|
|
18
|
+
return rad * 180 / Math.PI
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 水平角度转顺时针角
|
|
23
|
+
* @param {角度} angle
|
|
24
|
+
*/
|
|
25
|
+
toClockwiseAngle(angle) {
|
|
26
|
+
let a = 90 - angle
|
|
27
|
+
if (a < 0) {
|
|
28
|
+
a += 360
|
|
29
|
+
}
|
|
30
|
+
return a
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 求两点水平弧度
|
|
35
|
+
* @param {L.Point} a 起点
|
|
36
|
+
* @param {L.Point} b 终点
|
|
37
|
+
*/
|
|
38
|
+
computeRad(a, b) {
|
|
39
|
+
return Math.atan2(b.y - a.y, b.x - a.x)
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 求两点水平角度
|
|
44
|
+
* @param {L.Point} a 起点
|
|
45
|
+
* @param {L.Point} b 终点
|
|
46
|
+
*/
|
|
47
|
+
computeAngle(a, b) {
|
|
48
|
+
return this.radToAngle(this.computeRad(a, b))
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 获取线段夹角弧度
|
|
53
|
+
* @param {L.Point} a 交点
|
|
54
|
+
* @param {L.Point} b 终点一
|
|
55
|
+
* @param {L.Point} c 终点二
|
|
56
|
+
*/
|
|
57
|
+
segmentsRad(a, b, c) {
|
|
58
|
+
const x1 = b.x - a.x
|
|
59
|
+
const y1 = b.y - a.y
|
|
60
|
+
const x2 = c.x - a.x
|
|
61
|
+
const y2 = c.y - a.y
|
|
62
|
+
|
|
63
|
+
const dot = x1 * x2 + y1 * y2
|
|
64
|
+
const det = x1 * y2 - y1 * x2
|
|
65
|
+
|
|
66
|
+
return Math.atan2(det, dot)
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 获取点到线段所在直线的垂足
|
|
71
|
+
* @param {L.Point} a 点
|
|
72
|
+
* @param {L.Point} m 线段起点
|
|
73
|
+
* @param {L.Point} n 线段终点
|
|
74
|
+
*/
|
|
75
|
+
footPointOnLine(a, m, n) {
|
|
76
|
+
const s = (m.x - n.x) * (m.x - n.x) + (m.y - n.y) * (m.y - n.y)
|
|
77
|
+
const p = (a.x - m.x) * (n.x - m.x) + (a.y - m.y) * (n.y - m.y)
|
|
78
|
+
const r = p / s
|
|
79
|
+
const x = m.x + r * (n.x - m.x)
|
|
80
|
+
const y = m.y + r * (n.y - m.y)
|
|
81
|
+
|
|
82
|
+
return L.point(x, y)
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 两线段所在直线的交点坐标,平行或共线时不返回
|
|
87
|
+
* @param {L.Point} a 线段一起点
|
|
88
|
+
* @param {L.Point} b 线段一终点
|
|
89
|
+
* @param {L.Point} c 线段二起点
|
|
90
|
+
* @param {L.Point} d 线段二终点
|
|
91
|
+
*/
|
|
92
|
+
linesIntersection(a, b, c, d) {
|
|
93
|
+
const denominator = (b.y - a.y) * (d.x - c.x) - (a.x - b.x) * (c.y - d.y)
|
|
94
|
+
if (denominator) {
|
|
95
|
+
const x = ((b.x - a.x) * (d.x - c.x) * (c.y - a.y) +
|
|
96
|
+
(b.y - a.y) * (d.x - c.x) * a.x -
|
|
97
|
+
(d.y - c.y) * (b.x - a.x) * c.x) / denominator
|
|
98
|
+
const y = -((b.y - a.y) * (d.y - c.y) * (c.x - a.x) +
|
|
99
|
+
(b.x - a.x) * (d.y - c.y) * a.y -
|
|
100
|
+
(d.x - c.x) * (b.y - a.y) * c.y) / denominator
|
|
101
|
+
|
|
102
|
+
return L.point(x, y)
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 根据经纬度计算累计距离,单位米
|
|
108
|
+
* @param {Array<L.LatLng>} latLngs
|
|
109
|
+
* @param {L.CRS} 坐标系,默认使用L.CRS.EPSG3857
|
|
110
|
+
*/
|
|
111
|
+
distanceByLatLngs(latLngs, crs = L.CRS.EPSG3857) {
|
|
112
|
+
if (typeof (crs.distance) !== 'function') {
|
|
113
|
+
crs = L.CRS.EPSG3857
|
|
114
|
+
}
|
|
115
|
+
let sum = 0
|
|
116
|
+
if (Array.isArray(latLngs) && latLngs.length > 1) {
|
|
117
|
+
for (let i = 0; i < latLngs.length - 1; i++) {
|
|
118
|
+
sum += crs.distance(latLngs[i], latLngs[i + 1])
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return sum
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 根据经纬度计算面积,单位平方米
|
|
126
|
+
* @param {Array<L.LatLng>} latLngs
|
|
127
|
+
*/
|
|
128
|
+
areaByLatLngs(latLngs) {
|
|
129
|
+
let pointsCount = latLngs.length,
|
|
130
|
+
area = 0.0,
|
|
131
|
+
d2r = Math.PI / 180,
|
|
132
|
+
p1, p2
|
|
133
|
+
|
|
134
|
+
if (pointsCount > 2) {
|
|
135
|
+
for (let i = 0; i < pointsCount; i++) {
|
|
136
|
+
p1 = latLngs[i]
|
|
137
|
+
p2 = latLngs[(i + 1) % pointsCount]
|
|
138
|
+
area += ((p2.lng - p1.lng) * d2r) * (2 + Math.sin(p1.lat * d2r) + Math.sin(p2.lat * d2r))
|
|
139
|
+
}
|
|
140
|
+
area = area * 6378137.0 * 6378137.0 / 2.0
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return Math.abs(area)
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 根据坐标点计算面积
|
|
148
|
+
* @param {Array<L.Point>} points
|
|
149
|
+
*/
|
|
150
|
+
areaByPoints(points) {
|
|
151
|
+
let area = 0
|
|
152
|
+
if (Array.isArray(points) && points.length > 2) {
|
|
153
|
+
let sum = 0
|
|
154
|
+
for (let i = 0; i < points.length; i++) {
|
|
155
|
+
if (i + 1 == points.length) {
|
|
156
|
+
sum += points[i].x * points[0].y - points[0].x * points[i].y
|
|
157
|
+
} else {
|
|
158
|
+
sum += (points[i].x * points[i + 1].y - points[i + 1].x * points[i].y)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
area = 1 / 2 * Math.abs(sum)
|
|
162
|
+
}
|
|
163
|
+
return area
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* 转换面积,增加单位
|
|
168
|
+
* @param {number} area 面积数字,单位平方米
|
|
169
|
+
*/
|
|
170
|
+
readableArea(area) {
|
|
171
|
+
let areaStr = 0
|
|
172
|
+
if (area > 1000 * 1000) {
|
|
173
|
+
areaStr = (area / (1000 * 1000)).toFixed(2) + ' km²';
|
|
174
|
+
} else {
|
|
175
|
+
areaStr = Math.ceil(area) + ' m²';
|
|
176
|
+
}
|
|
177
|
+
return areaStr
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* 点是否在多边形内,射线法
|
|
182
|
+
* @param {L.Point} point 给定点
|
|
183
|
+
* @param {Array<L.Point>} points 多边形坐标
|
|
184
|
+
* @returns {Boolean} 是否置于多边形内或边界上
|
|
185
|
+
*/
|
|
186
|
+
isPointInPoly(point, points) {
|
|
187
|
+
const px = point.x
|
|
188
|
+
const py = point.y
|
|
189
|
+
let flag = false
|
|
190
|
+
|
|
191
|
+
// 是否置于边界上
|
|
192
|
+
let isOn = false
|
|
193
|
+
// 遍历边界
|
|
194
|
+
const length = points.length
|
|
195
|
+
for (let i = 0, j = length - 1; i < length; j = i, i++) {
|
|
196
|
+
const sx = points[i].x
|
|
197
|
+
const sy = points[i].y
|
|
198
|
+
const tx = points[j].x
|
|
199
|
+
const ty = points[j].y
|
|
200
|
+
|
|
201
|
+
// 点与多边形顶点重合
|
|
202
|
+
if ((sx === px && sy === py) || (tx === px && ty === py)) {
|
|
203
|
+
isOn = true
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// 判断线段两端点是否在射线两侧
|
|
207
|
+
if ((sy < py && ty >= py) || (sy >= py && ty < py)) {
|
|
208
|
+
// 线段上与射线Y坐标相同的点的X坐标
|
|
209
|
+
const x = sx + (py - sy) * (tx - sx) / (ty - sy)
|
|
210
|
+
// 点在多边形的边上
|
|
211
|
+
isOn = (x === px)
|
|
212
|
+
// 射线穿过边界
|
|
213
|
+
if (x > px) {
|
|
214
|
+
flag = !flag
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (isOn) {
|
|
218
|
+
break
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return isOn || flag
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* 点到面的距离,在内部视为0
|
|
227
|
+
* @param {L.Point} point 给定点
|
|
228
|
+
* @param {Array<L.Point>} points 多边形坐标
|
|
229
|
+
* @param {L.CRS} crs 地图CRS
|
|
230
|
+
* @returns {Boolean} 距离数值,若CRS可用,单位为米
|
|
231
|
+
*/
|
|
232
|
+
distanceToPoly(point, points, crs) {
|
|
233
|
+
let result = 0
|
|
234
|
+
if (!this.isPointInPoly(point, points)) {
|
|
235
|
+
let distances = []
|
|
236
|
+
let ps = []
|
|
237
|
+
const length = points.length
|
|
238
|
+
for (let i = 0, j = length - 1; i < length; j = i, i++) {
|
|
239
|
+
distances.push(L.LineUtil.pointToSegmentDistance(point, points[i], points[j]))
|
|
240
|
+
ps.push(L.LineUtil.closestPointOnSegment(point, points[i], points[j]))
|
|
241
|
+
}
|
|
242
|
+
result = _.min(distances)
|
|
243
|
+
const index = _.indexOf(distances, result)
|
|
244
|
+
const closePoint = ps[index]
|
|
245
|
+
if (crs && crs.unproject) {
|
|
246
|
+
const latLng1 = crs.unproject(point)
|
|
247
|
+
const latLng2 = crs.unproject(closePoint)
|
|
248
|
+
result = crs.distance(latLng1, latLng2)
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return result
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* 点到折线的距离
|
|
256
|
+
* @param {L.Point} point 给定点
|
|
257
|
+
* @param {Array<L.Point>} points 折线坐标
|
|
258
|
+
* @param {L.CRS} crs 地图CRS
|
|
259
|
+
* @param {Boolean} 距离数值,若CRS可用,单位为米
|
|
260
|
+
*/
|
|
261
|
+
distanceToLine(point, points, crs) {
|
|
262
|
+
let result = 0
|
|
263
|
+
let distances = []
|
|
264
|
+
let ps = []
|
|
265
|
+
if (Array.isArray(points) && points.length > 1) {
|
|
266
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
267
|
+
distances.push(L.LineUtil.pointToSegmentDistance(point, points[i], points[i + 1]))
|
|
268
|
+
ps.push(L.LineUtil.closestPointOnSegment(point, points[i], points[i + 1]))
|
|
269
|
+
}
|
|
270
|
+
result = _.min(distances)
|
|
271
|
+
const index = _.indexOf(distances, result)
|
|
272
|
+
const closePoint = ps[index]
|
|
273
|
+
if (crs && crs.unproject) {
|
|
274
|
+
const latLng1 = crs.unproject(point)
|
|
275
|
+
const latLng2 = crs.unproject(closePoint)
|
|
276
|
+
result = crs.distance(latLng1, latLng2)
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return result
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
L.GeoUtil = L.extend(L.GeoUtil || {}, _.assign(fns, buffer))
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import './style.less'
|
|
2
|
+
|
|
3
|
+
L.Glyphicon = L.DivIcon.extend({
|
|
4
|
+
|
|
5
|
+
options: {
|
|
6
|
+
icon: 'fas fa-leaf',
|
|
7
|
+
size: 32,
|
|
8
|
+
fontSize: null,
|
|
9
|
+
background: 'white',
|
|
10
|
+
color: '#4d90fe',
|
|
11
|
+
borderRadius: null,
|
|
12
|
+
borderWidth: 2,
|
|
13
|
+
borderColor: null,
|
|
14
|
+
boxShadow: true,
|
|
15
|
+
additionalCSS: '',
|
|
16
|
+
className: '',
|
|
17
|
+
effect: {
|
|
18
|
+
type: null,
|
|
19
|
+
size: null,
|
|
20
|
+
color: null,
|
|
21
|
+
interval: null
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
initialize(options = {}) {
|
|
26
|
+
L.setOptions(this, options)
|
|
27
|
+
|
|
28
|
+
// 图标元素-外层
|
|
29
|
+
let args = this.options
|
|
30
|
+
let container = document.createElement('div')
|
|
31
|
+
L.DomUtil.addClass(container, 'vae-glyphicon')
|
|
32
|
+
let style = []
|
|
33
|
+
style.push(`height:${args.size - args.borderWidth * 2}px`)
|
|
34
|
+
style.push(`width:${args.size - args.borderWidth * 2}px`)
|
|
35
|
+
style.push(`color:${args.color}`)
|
|
36
|
+
let fontSize = _.isNil(args.fontSize) ? args.size / 2 : args.fontSize
|
|
37
|
+
style.push(`font-size:${fontSize}px`)
|
|
38
|
+
let borderRadius = _.isNil(args.borderRadius) ? args.size : args.borderRadius
|
|
39
|
+
style.push(`border-radius:${borderRadius}px`)
|
|
40
|
+
style.push(`border-width:${args.borderWidth}px`)
|
|
41
|
+
style.push(`border-color:${args.borderColor || args.color}`)
|
|
42
|
+
style.push("border-style:solid")
|
|
43
|
+
style.push(`background-color:${args.background}`)
|
|
44
|
+
if (args.boxShadow) {
|
|
45
|
+
style.push("box-shadow:0 2px 6px 0 rgba(0, 0, 0, 0.2)")
|
|
46
|
+
}
|
|
47
|
+
style.push(args.additionalCSS)
|
|
48
|
+
let styleAttributes = document.createAttribute("style")
|
|
49
|
+
styleAttributes.value = style.join(";")
|
|
50
|
+
|
|
51
|
+
// 图标元素-内层
|
|
52
|
+
let iconElement = document.createElement("div")
|
|
53
|
+
L.DomUtil.addClass(iconElement, args.icon)
|
|
54
|
+
|
|
55
|
+
container.setAttributeNode(styleAttributes)
|
|
56
|
+
container.appendChild(iconElement)
|
|
57
|
+
|
|
58
|
+
// 特效元素
|
|
59
|
+
let effect = args.effect
|
|
60
|
+
if (effect && effect.type) {
|
|
61
|
+
let effectElement = document.createElement('div')
|
|
62
|
+
let effectType = effect.type
|
|
63
|
+
if (effectType === 'halo') {
|
|
64
|
+
let effectStyleAttributes = document.createAttribute("style")
|
|
65
|
+
let effectStyles = []
|
|
66
|
+
L.DomUtil.addClass(effectElement, 'halo')
|
|
67
|
+
let effectSize = effect.size || args.size * 3
|
|
68
|
+
effectStyles.push(`height:${effectSize}px`)
|
|
69
|
+
effectStyles.push(`width:${effectSize}px`)
|
|
70
|
+
let effectColor = effect.color || args.color
|
|
71
|
+
effectStyles.push(`background-color:${effectColor}`)
|
|
72
|
+
effectStyles.push(`top:-${(effectSize - args.size) / 2}px`)
|
|
73
|
+
effectStyles.push(`left:-${(effectSize - args.size) / 2}px`)
|
|
74
|
+
effectStyles.push(`animation:vae-effect-${effectType} ${effect.interval || 2}s 0s infinite ease-in`)
|
|
75
|
+
effectStyleAttributes.value = effectStyles.join(";")
|
|
76
|
+
effectElement.setAttributeNode(effectStyleAttributes)
|
|
77
|
+
}
|
|
78
|
+
container.appendChild(effectElement)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
L.DivIcon.prototype.initialize.call(this, {
|
|
82
|
+
html: container.outerHTML,
|
|
83
|
+
iconSize: [args.size, args.size],
|
|
84
|
+
className: args.className
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
L.glyphicon = function (options) {
|
|
90
|
+
return new L.Glyphicon(options)
|
|
91
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.vae-glyphicon {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
|
|
6
|
+
.halo {
|
|
7
|
+
border-radius: 50% 50%;
|
|
8
|
+
position: absolute;
|
|
9
|
+
pointer-events: none;
|
|
10
|
+
z-index: -1;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// 光晕扩散
|
|
15
|
+
@keyframes vae-effect-halo {
|
|
16
|
+
0% {
|
|
17
|
+
transform: scale(0.2);
|
|
18
|
+
opacity: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
65% {
|
|
22
|
+
opacity: 0.75;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
75% {
|
|
26
|
+
opacity: 0.75;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
85% {
|
|
30
|
+
opacity: 0.2;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
100% {
|
|
34
|
+
transform: scale(1);
|
|
35
|
+
opacity: 0;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import './style.less'
|
|
2
|
+
|
|
3
|
+
// 自定义聚合图标
|
|
4
|
+
function iconCreateFunction(cluster) {
|
|
5
|
+
|
|
6
|
+
// 尺寸和颜色设六个级别
|
|
7
|
+
let level = 1
|
|
8
|
+
let iconSize = 30
|
|
9
|
+
let borderSize = 6
|
|
10
|
+
|
|
11
|
+
const count = cluster.getChildCount()
|
|
12
|
+
// 0-9
|
|
13
|
+
if (count > 0 && count <= 9) {
|
|
14
|
+
level = 1
|
|
15
|
+
iconSize = 30
|
|
16
|
+
borderSize = 6
|
|
17
|
+
}
|
|
18
|
+
// 10-49
|
|
19
|
+
else if (count > 9 && count <= 49) {
|
|
20
|
+
level = 2
|
|
21
|
+
iconSize = 38
|
|
22
|
+
borderSize = 8
|
|
23
|
+
}
|
|
24
|
+
// 50-99
|
|
25
|
+
else if (count > 49 && count <= 99) {
|
|
26
|
+
level = 3
|
|
27
|
+
iconSize = 46
|
|
28
|
+
borderSize = 8
|
|
29
|
+
}
|
|
30
|
+
// 100-499
|
|
31
|
+
else if (count > 99 && count <= 499) {
|
|
32
|
+
level = 4
|
|
33
|
+
iconSize = 54
|
|
34
|
+
borderSize = 10
|
|
35
|
+
}
|
|
36
|
+
// 500-999
|
|
37
|
+
else if (count > 499 && count < 999) {
|
|
38
|
+
level = 5
|
|
39
|
+
iconSize = 62
|
|
40
|
+
borderSize = 10
|
|
41
|
+
}
|
|
42
|
+
// 999+
|
|
43
|
+
else {
|
|
44
|
+
level = 6
|
|
45
|
+
iconSize = 70
|
|
46
|
+
borderSize = 12
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const className = `vae-markercluster--icon style--${this.iconStyle || 'blue'} level--${level}`
|
|
50
|
+
const innerSize = iconSize - borderSize
|
|
51
|
+
|
|
52
|
+
const outerStyle = `border-radius:${iconSize / 2}px;`
|
|
53
|
+
const innerStyle = `height:${innerSize}px;width:${innerSize}px;border-radius:${innerSize / 2}px;`
|
|
54
|
+
|
|
55
|
+
return L.divIcon({
|
|
56
|
+
html: `<div class="outer center" style="${outerStyle}"><div class="inner center" style="${innerStyle}">${count}</div></div>`,
|
|
57
|
+
className,
|
|
58
|
+
iconSize: [iconSize, iconSize]
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
L.MarkerClusterGroupX = L.MarkerClusterGroup.extend({
|
|
63
|
+
|
|
64
|
+
options: {
|
|
65
|
+
iconStyle: 'blue',
|
|
66
|
+
showCoverageOnHover: false,
|
|
67
|
+
maxClusterRadius: 60,
|
|
68
|
+
spiderLegPolylineOptions: {
|
|
69
|
+
weight: 2,
|
|
70
|
+
dashArray: [5, 5],
|
|
71
|
+
interactive: false,
|
|
72
|
+
opacity: 0.8
|
|
73
|
+
},
|
|
74
|
+
iconCreateFunction
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
initialize(options = {}) {
|
|
78
|
+
L.setOptions(this, options)
|
|
79
|
+
const iconStyle = this.options.iconStyle || 'blue'
|
|
80
|
+
this.options.spiderLegPolylineOptions.color =
|
|
81
|
+
iconStyle == 'red' ? 'hsl(354, 70%, 54%)' : iconStyle == 'blue' ? 'hsl(211, 100%, 45%)' : iconStyle == 'green' ? 'hsl(134, 61%, 41%)'
|
|
82
|
+
: iconStyle == 'gray' ? '#606266' : iconStyle == 'yellow' ? '#f9c31f' : iconStyle == 'orange' ? '#fd7e14'
|
|
83
|
+
: iconStyle == 'cyan' ? '#17a2b8' : iconStyle == 'purple' ? '#5c11d4' : iconStyle == 'pink' ? '#e83e8c'
|
|
84
|
+
: iconStyle == 'transparent' ? 'rgba(0,0,0,0.6)' : null
|
|
85
|
+
|
|
86
|
+
L.MarkerClusterGroup.prototype.initialize.call(this, this.options)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
L.markerClusterGroupX = function (options) {
|
|
92
|
+
return new L.MarkerClusterGroupX(options)
|
|
93
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// 聚合图标
|
|
2
|
+
.vae-markercluster--icon {
|
|
3
|
+
|
|
4
|
+
.outer {
|
|
5
|
+
height: 100%;
|
|
6
|
+
width: 100%;
|
|
7
|
+
font-size: 12px;
|
|
8
|
+
|
|
9
|
+
.inner {
|
|
10
|
+
color: white;
|
|
11
|
+
font-weight: bold;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.center {
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// 红色
|
|
22
|
+
each(range(6), {
|
|
23
|
+
&.style--red.level--@{value} {
|
|
24
|
+
.outer {
|
|
25
|
+
background: darken(#ff7d52, @value * 2%);
|
|
26
|
+
|
|
27
|
+
.inner {
|
|
28
|
+
background: darken(hsl(354, 70%, 54%), @value * 3%);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
// 橙色
|
|
36
|
+
each(range(6), {
|
|
37
|
+
&.style--orange.level--@{value} {
|
|
38
|
+
.outer {
|
|
39
|
+
background: darken(#f9c31f, @value * 1%);
|
|
40
|
+
|
|
41
|
+
.inner {
|
|
42
|
+
background: darken(#fd7e14, @value * 2%);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
// 黄色
|
|
50
|
+
each(range(6), {
|
|
51
|
+
&.style--yellow.level--@{value} {
|
|
52
|
+
.outer {
|
|
53
|
+
background: darken(#fdfd77, @value * 2%);
|
|
54
|
+
|
|
55
|
+
.inner {
|
|
56
|
+
background: darken(#f9c31f, @value * 3%);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
// 蓝色
|
|
64
|
+
each(range(6), {
|
|
65
|
+
&.style--blue.level--@{value} {
|
|
66
|
+
.outer {
|
|
67
|
+
background: darken(hsl(200, 100%, 67%), @value * 2%);
|
|
68
|
+
|
|
69
|
+
.inner {
|
|
70
|
+
background: darken(hsl(211, 100%, 45%), @value * 3%);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
// 绿色
|
|
78
|
+
each(range(6), {
|
|
79
|
+
&.style--green.level--@{value} {
|
|
80
|
+
.outer {
|
|
81
|
+
background: darken(hsl(100, 54%, 58%), @value * 2%);
|
|
82
|
+
|
|
83
|
+
.inner {
|
|
84
|
+
background: darken(hsl(134, 61%, 41%), @value * 3%);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
// 青绿
|
|
92
|
+
each(range(6), {
|
|
93
|
+
&.style--cyan.level--@{value} {
|
|
94
|
+
.outer {
|
|
95
|
+
background: darken(aqua, @value * 1%);
|
|
96
|
+
|
|
97
|
+
.inner {
|
|
98
|
+
background: darken(#17a2b8, @value * 2%);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
// 紫色
|
|
106
|
+
each(range(6), {
|
|
107
|
+
&.style--purple.level--@{value} {
|
|
108
|
+
.outer {
|
|
109
|
+
background: darken(hsl(211, 90%, 70%), @value * 2%);
|
|
110
|
+
|
|
111
|
+
.inner {
|
|
112
|
+
background: darken(#5c11d4, @value * 3%);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
// 粉色
|
|
120
|
+
each(range(6), {
|
|
121
|
+
&.style--pink.level--@{value} {
|
|
122
|
+
.outer {
|
|
123
|
+
background: darken(#f7bac9, @value * 2%);
|
|
124
|
+
|
|
125
|
+
.inner {
|
|
126
|
+
background: darken(#e83e8c, @value * 3%);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
// 灰色
|
|
135
|
+
each(range(6), {
|
|
136
|
+
&.style--gray.level--@{value} {
|
|
137
|
+
.outer {
|
|
138
|
+
background: darken(#c0c4cc, @value * 2%);
|
|
139
|
+
|
|
140
|
+
.inner {
|
|
141
|
+
background: darken(#606266, @value * 3%);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
// 透明
|
|
149
|
+
each(range(6), {
|
|
150
|
+
&.style--transparent.level--@{value} {
|
|
151
|
+
.outer {
|
|
152
|
+
background: darken(rgba(0,0,0,0.2), @value * 2%);
|
|
153
|
+
|
|
154
|
+
.inner {
|
|
155
|
+
background: darken(rgba(0,0,0,0.6), @value * 3%);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
}
|