@vortex-ui/env-puzzle 2.0.0-beta.8 → 3.0.0-beta.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 (198) hide show
  1. package/lib/b-map/b-map.d.ts +1 -1
  2. package/lib/b-map/b-map.js +100 -162
  3. package/lib/b-map/b-map.js.map +1 -1
  4. package/lib/b-map/custom-overlay.js +17 -37
  5. package/lib/b-map/custom-overlay.js.map +1 -1
  6. package/lib/b-map/drawing.js +11 -25
  7. package/lib/b-map/drawing.js.map +1 -1
  8. package/lib/b-map/index.d.ts +2 -2
  9. package/lib/b-map/index.js +4 -16
  10. package/lib/b-map/index.js.map +1 -1
  11. package/lib/b-map/js/marker-clusterer.js +42 -158
  12. package/lib/b-map/js/marker-clusterer.js.map +1 -1
  13. package/lib/b-map/lushu.js +17 -36
  14. package/lib/b-map/lushu.js.map +1 -1
  15. package/lib/b-map/marker-clusterer.js +6 -14
  16. package/lib/b-map/marker-clusterer.js.map +1 -1
  17. package/lib/b-map/marker.js +32 -70
  18. package/lib/b-map/marker.js.map +1 -1
  19. package/lib/b-map/polygon.js +5 -13
  20. package/lib/b-map/polygon.js.map +1 -1
  21. package/lib/b-map/style/css.js.map +1 -1
  22. package/lib/b-map/style/index.js.map +1 -1
  23. package/lib/create-modal/create-modal.js +149 -287
  24. package/lib/create-modal/create-modal.js.map +1 -1
  25. package/lib/create-modal/index.d.ts +1 -2
  26. package/lib/create-modal/index.js +2 -8
  27. package/lib/create-modal/index.js.map +1 -1
  28. package/lib/create-modal/style/css.js +0 -18
  29. package/lib/create-modal/style/css.js.map +1 -1
  30. package/lib/create-modal/style/index.css +2 -2
  31. package/lib/create-modal/style/index.d.ts +0 -9
  32. package/lib/create-modal/style/index.js +0 -18
  33. package/lib/create-modal/style/index.js.map +1 -1
  34. package/lib/create-modal/style/index.less +21 -27
  35. package/lib/global.less +0 -6
  36. package/lib/import-modal/import-modal.d.ts +2 -0
  37. package/lib/import-modal/import-modal.js +133 -192
  38. package/lib/import-modal/import-modal.js.map +1 -1
  39. package/lib/import-modal/index.js +2 -6
  40. package/lib/import-modal/index.js.map +1 -1
  41. package/lib/import-modal/style/css.js +0 -10
  42. package/lib/import-modal/style/css.js.map +1 -1
  43. package/lib/import-modal/style/index.d.ts +0 -5
  44. package/lib/import-modal/style/index.js +0 -10
  45. package/lib/import-modal/style/index.js.map +1 -1
  46. package/lib/import-modal/style/index.less +0 -1
  47. package/lib/index.js +1 -14
  48. package/lib/index.js.map +1 -1
  49. package/lib/interface/index.js.map +1 -1
  50. package/lib/mapv-Layer/Function.js +0 -2
  51. package/lib/mapv-Layer/Function.js.map +1 -1
  52. package/lib/mapv-Layer/index.js +2 -6
  53. package/lib/mapv-Layer/index.js.map +1 -1
  54. package/lib/mapv-Layer/mapv-Layer.js +19 -40
  55. package/lib/mapv-Layer/mapv-Layer.js.map +1 -1
  56. package/lib/mapv-Layer/style/css.js.map +1 -1
  57. package/lib/mapv-Layer/style/index.js.map +1 -1
  58. package/lib/percent/index.d.ts +1 -1
  59. package/lib/percent/index.js +2 -7
  60. package/lib/percent/index.js.map +1 -1
  61. package/lib/percent/interface.js.map +1 -1
  62. package/lib/percent/line-percent.js +20 -37
  63. package/lib/percent/line-percent.js.map +1 -1
  64. package/lib/percent/percent.js +20 -43
  65. package/lib/percent/percent.js.map +1 -1
  66. package/lib/percent/style/css.js.map +1 -1
  67. package/lib/percent/style/index.js.map +1 -1
  68. package/lib/scroll/index.js +2 -6
  69. package/lib/scroll/index.js.map +1 -1
  70. package/lib/scroll/scroll.d.ts +1 -1
  71. package/lib/scroll/scroll.js +19 -47
  72. package/lib/scroll/scroll.js.map +1 -1
  73. package/lib/scroll/style/css.js.map +1 -1
  74. package/lib/scroll/style/index.js.map +1 -1
  75. package/lib/scroll-select/index.js +2 -6
  76. package/lib/scroll-select/index.js.map +1 -1
  77. package/lib/scroll-select/scrollSelect.d.ts +2 -1
  78. package/lib/scroll-select/scrollSelect.js +141 -215
  79. package/lib/scroll-select/scrollSelect.js.map +1 -1
  80. package/lib/scroll-select/style/css.js +0 -2
  81. package/lib/scroll-select/style/css.js.map +1 -1
  82. package/lib/scroll-select/style/index.d.ts +0 -1
  83. package/lib/scroll-select/style/index.js +0 -2
  84. package/lib/scroll-select/style/index.js.map +1 -1
  85. package/lib/table/index.js +2 -6
  86. package/lib/table/index.js.map +1 -1
  87. package/lib/table/style/css.js +0 -2
  88. package/lib/table/style/css.js.map +1 -1
  89. package/lib/table/style/index.d.ts +0 -1
  90. package/lib/table/style/index.js +0 -2
  91. package/lib/table/style/index.js.map +1 -1
  92. package/lib/table/table.js +22 -54
  93. package/lib/table/table.js.map +1 -1
  94. package/lib/template/action.d.ts +3 -1
  95. package/lib/template/action.js +80 -116
  96. package/lib/template/action.js.map +1 -1
  97. package/lib/template/card-table.d.ts +4 -4
  98. package/lib/template/card-table.js +40 -82
  99. package/lib/template/card-table.js.map +1 -1
  100. package/lib/template/card.d.ts +1 -1
  101. package/lib/template/card.js +20 -38
  102. package/lib/template/card.js.map +1 -1
  103. package/lib/template/check-row.d.ts +2 -1
  104. package/lib/template/check-row.js +7 -12
  105. package/lib/template/check-row.js.map +1 -1
  106. package/lib/template/field.js +8 -24
  107. package/lib/template/field.js.map +1 -1
  108. package/lib/template/filter.js +19 -54
  109. package/lib/template/filter.js.map +1 -1
  110. package/lib/template/icon.js +4 -15
  111. package/lib/template/icon.js.map +1 -1
  112. package/lib/template/index.d.ts +2 -3
  113. package/lib/template/index.js +4 -12
  114. package/lib/template/index.js.map +1 -1
  115. package/lib/template/interface.js.map +1 -1
  116. package/lib/template/renderColumnButtons.js +62 -93
  117. package/lib/template/renderColumnButtons.js.map +1 -1
  118. package/lib/template/style/action.css +3 -2
  119. package/lib/template/style/action.less +10 -7
  120. package/lib/template/style/card.css +2 -2
  121. package/lib/template/style/card.less +2 -3
  122. package/lib/template/style/css.js +0 -36
  123. package/lib/template/style/css.js.map +1 -1
  124. package/lib/template/style/index.css +8 -13
  125. package/lib/template/style/index.d.ts +0 -18
  126. package/lib/template/style/index.js +0 -36
  127. package/lib/template/style/index.js.map +1 -1
  128. package/lib/template/style/index.less +3 -4
  129. package/lib/template/style/table.css +0 -6
  130. package/lib/template/style/table.less +6 -11
  131. package/lib/template/table.d.ts +5 -4
  132. package/lib/template/table.js +19 -37
  133. package/lib/template/table.js.map +1 -1
  134. package/lib/template/template.d.ts +2 -2
  135. package/lib/template/template.js +115 -193
  136. package/lib/template/template.js.map +1 -1
  137. package/lib/template/toolbar.d.ts +1 -1
  138. package/lib/template/toolbar.js +52 -56
  139. package/lib/template/toolbar.js.map +1 -1
  140. package/lib/to-map/container.js +48 -95
  141. package/lib/to-map/container.js.map +1 -1
  142. package/lib/to-map/draw-area.js +12 -32
  143. package/lib/to-map/draw-area.js.map +1 -1
  144. package/lib/to-map/index.d.ts +1 -1
  145. package/lib/to-map/index.js +2 -7
  146. package/lib/to-map/index.js.map +1 -1
  147. package/lib/to-map/style/css.js +0 -2
  148. package/lib/to-map/style/css.js.map +1 -1
  149. package/lib/to-map/style/index.d.ts +0 -1
  150. package/lib/to-map/style/index.js +0 -2
  151. package/lib/to-map/style/index.js.map +1 -1
  152. package/lib/to-map/to-map.js +20 -47
  153. package/lib/to-map/to-map.js.map +1 -1
  154. package/lib/upload/index.js +2 -6
  155. package/lib/upload/index.js.map +1 -1
  156. package/lib/upload/style/css.js +0 -5
  157. package/lib/upload/style/css.js.map +1 -1
  158. package/lib/upload/style/index.d.ts +0 -2
  159. package/lib/upload/style/index.js +0 -5
  160. package/lib/upload/style/index.js.map +1 -1
  161. package/lib/upload/upload.d.ts +3 -0
  162. package/lib/upload/upload.js +158 -237
  163. package/lib/upload/upload.js.map +1 -1
  164. package/lib/use-simple-res/demos/index.d.ts +2 -1
  165. package/lib/use-simple-res/demos/index.js +31 -59
  166. package/lib/use-simple-res/demos/index.js.map +1 -1
  167. package/lib/use-simple-res/index.js +60 -73
  168. package/lib/use-simple-res/index.js.map +1 -1
  169. package/lib/use-simple-res/style/css.js.map +1 -1
  170. package/lib/use-simple-res/style/index.js.map +1 -1
  171. package/lib/utils/dom-util.js +8 -27
  172. package/lib/utils/dom-util.js.map +1 -1
  173. package/lib/utils/request-util.d.ts +10 -1
  174. package/lib/utils/request-util.js +170 -45
  175. package/lib/utils/request-util.js.map +1 -1
  176. package/lib/utils/string-util.d.ts +2 -0
  177. package/lib/utils/string-util.js +34 -16
  178. package/lib/utils/string-util.js.map +1 -1
  179. package/lib/view-modal/index.d.ts +0 -1
  180. package/lib/view-modal/index.js +2 -8
  181. package/lib/view-modal/index.js.map +1 -1
  182. package/lib/view-modal/style/css.js +0 -12
  183. package/lib/view-modal/style/css.js.map +1 -1
  184. package/lib/view-modal/style/index.css +3 -41
  185. package/lib/view-modal/style/index.d.ts +0 -7
  186. package/lib/view-modal/style/index.js +0 -12
  187. package/lib/view-modal/style/index.js.map +1 -1
  188. package/lib/view-modal/style/index.less +3 -18
  189. package/lib/view-modal/view-modal.js +28 -75
  190. package/lib/view-modal/view-modal.js.map +1 -1
  191. package/package.json +37 -23
  192. package/lib/style/css.js +0 -13
  193. package/lib/style/css.js.map +0 -1
  194. package/lib/style/darkGreen.css +0 -631
  195. package/lib/style/darkGreen.less +0 -370
  196. package/lib/style/index.d.ts +0 -2
  197. package/lib/style/index.js +0 -13
  198. package/lib/style/index.js.map +0 -1
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  /* eslint-disable*/
4
-
5
4
  /**
6
5
  * @fileoverview MarkerClusterer标记聚合器用来解决加载大量点要素到地图上产生覆盖现象的问题,并提高性能。
7
6
  * 主入口类是<a href="symbols/BMapLib.MarkerClusterer.html">MarkerClusterer</a>,
@@ -15,7 +14,6 @@
15
14
  * @namespace BMap的所有library类均放在BMapLib命名空间下
16
15
  */
17
16
  var BMapLib = window.BMapLib = BMapLib || {};
18
-
19
17
  (function () {
20
18
  /**
21
19
  * 获取一个扩展的视图范围,把上下左右都扩大一样的像素值。
@@ -37,14 +35,13 @@ var BMapLib = window.BMapLib = BMapLib || {};
37
35
  var newSW = map.pixelToPoint(pixelSW);
38
36
  return new BMap.Bounds(newSW, newNE);
39
37
  };
38
+
40
39
  /**
41
40
  * 按照百度地图支持的世界范围对bounds进行边界处理
42
41
  * @param {BMap.Bounds} bounds BMap.Bounds的实例化对象
43
42
  *
44
43
  * @return {BMap.Bounds} 返回不越界的视图范围
45
44
  */
46
-
47
-
48
45
  var cutBoundsInRange = function cutBoundsInRange(bounds) {
49
46
  var maxX = getRange(bounds.getNorthEast().lng, -180, 180);
50
47
  var minX = getRange(bounds.getSouthWest().lng, -180, 180);
@@ -52,6 +49,7 @@ var BMapLib = window.BMapLib = BMapLib || {};
52
49
  var minY = getRange(bounds.getSouthWest().lat, -74, 74);
53
50
  return new BMap.Bounds(new BMap.Point(minX, minY), new BMap.Point(maxX, maxY));
54
51
  };
52
+
55
53
  /**
56
54
  * 对单个值进行边界处理。
57
55
  * @param {Number} i 要处理的数值
@@ -60,24 +58,22 @@ var BMapLib = window.BMapLib = BMapLib || {};
60
58
  *
61
59
  * @return {Number} 返回不越界的数值
62
60
  */
63
-
64
-
65
61
  var getRange = function getRange(i, mix, max) {
66
62
  mix && (i = Math.max(i, mix));
67
63
  max && (i = Math.min(i, max));
68
64
  return i;
69
65
  };
66
+
70
67
  /**
71
68
  * 判断给定的对象是否为数组
72
69
  * @param {Object} source 要测试的对象
73
70
  *
74
71
  * @return {Boolean} 如果是数组返回true,否则返回false
75
72
  */
76
-
77
-
78
73
  var isArray = function isArray(source) {
79
74
  return '[object Array]' === Object.prototype.toString.call(source);
80
75
  };
76
+
81
77
  /**
82
78
  * 返回item在source中的索引位置
83
79
  * @param {Object} item 要测试的对象
@@ -85,11 +81,8 @@ var BMapLib = window.BMapLib = BMapLib || {};
85
81
  *
86
82
  * @return {Number} 如果在数组内,返回索引,否则返回-1
87
83
  */
88
-
89
-
90
84
  var indexOf = function indexOf(item, source) {
91
85
  var index = -1;
92
-
93
86
  if (isArray(source)) {
94
87
  if (source.indexOf) {
95
88
  index = source.indexOf(item);
@@ -102,14 +95,12 @@ var BMapLib = window.BMapLib = BMapLib || {};
102
95
  }
103
96
  }
104
97
  }
105
-
106
98
  return index;
107
99
  };
100
+
108
101
  /**
109
102
  *@exports MarkerClusterer as BMapLib.MarkerClusterer
110
103
  */
111
-
112
-
113
104
  var MarkerClusterer =
114
105
  /**
115
106
  * MarkerClusterer
@@ -128,7 +119,6 @@ var BMapLib = window.BMapLib = BMapLib || {};
128
119
  if (!map) {
129
120
  return;
130
121
  }
131
-
132
122
  this._map = map;
133
123
  this._markers = [];
134
124
  this._clusters = [];
@@ -137,392 +127,321 @@ var BMapLib = window.BMapLib = BMapLib || {};
137
127
  this._maxZoom = opts['maxZoom'] || 18;
138
128
  this._minClusterSize = opts['minClusterSize'] || 2;
139
129
  this._isAverageCenter = false;
140
-
141
130
  if (opts['isAverageCenter'] != undefined) {
142
131
  this._isAverageCenter = opts['isAverageCenter'];
143
132
  }
144
-
145
133
  this._styles = opts['styles'] || [];
146
134
  var that = this;
147
-
148
135
  this._map.addEventListener('zoomend', function () {
149
136
  that._redraw();
150
137
  });
151
-
152
138
  this._map.addEventListener('moveend', function () {
153
139
  that._redraw();
154
140
  });
155
-
156
141
  var mkrs = opts['markers'];
157
142
  isArray(mkrs) && this.addMarkers(mkrs);
158
143
  };
144
+
159
145
  /**
160
146
  * 添加要聚合的标记数组。
161
147
  * @param {Array<Marker>} markers 要聚合的标记数组
162
148
  *
163
149
  * @return 无返回值。
164
150
  */
165
-
166
-
167
151
  MarkerClusterer.prototype.addMarkers = function (markers) {
168
152
  for (var i = 0, len = markers.length; i < len; i++) {
169
153
  this._pushMarkerTo(markers[i]);
170
154
  }
171
-
172
155
  this._createClusters();
173
156
  };
157
+
174
158
  /**
175
159
  * 把一个标记添加到要聚合的标记数组中
176
160
  * @param {BMap.Marker} marker 要添加的标记
177
161
  *
178
162
  * @return 无返回值。
179
163
  */
180
-
181
-
182
164
  MarkerClusterer.prototype._pushMarkerTo = function (marker) {
183
165
  var index = indexOf(marker, this._markers);
184
-
185
166
  if (index === -1) {
186
167
  marker.isInCluster = false;
187
-
188
168
  this._markers.push(marker); //Marker拖放后enableDragging不做变化,忽略
189
-
190
169
  }
191
170
  };
171
+
192
172
  /**
193
173
  * 添加一个聚合的标记。
194
174
  * @param {BMap.Marker} marker 要聚合的单个标记。
195
175
  * @return 无返回值。
196
176
  */
197
-
198
-
199
177
  MarkerClusterer.prototype.addMarker = function (marker) {
200
178
  this._pushMarkerTo(marker);
201
-
202
179
  this._createClusters();
203
180
  };
181
+
204
182
  /**
205
183
  * 根据所给定的标记,创建聚合点,并且遍历所有聚合点
206
184
  * @return 无返回值
207
185
  */
208
-
209
-
210
186
  MarkerClusterer.prototype._createClusters = function () {
211
187
  var mapBounds = this._map.getBounds();
212
-
213
188
  var extendedBounds = getExtendedBounds(this._map, mapBounds, this._gridSize);
214
-
215
189
  for (var i = 0, marker; marker = this._markers[i]; i++) {
216
190
  if (!marker.isInCluster && extendedBounds.containsPoint(marker.getPosition())) {
217
191
  this._addToClosestCluster(marker);
218
192
  }
219
193
  }
220
-
221
194
  var len = this._markers.length;
222
-
223
195
  for (var i = 0; i < len; i++) {
224
196
  if (this._clusters[i]) {
225
197
  this._clusters[i].render();
226
198
  }
227
199
  }
228
200
  };
201
+
229
202
  /**
230
203
  * 根据标记的位置,把它添加到最近的聚合中
231
204
  * @param {BMap.Marker} marker 要进行聚合的单个标记
232
205
  *
233
206
  * @return 无返回值。
234
207
  */
235
-
236
-
237
208
  MarkerClusterer.prototype._addToClosestCluster = function (marker) {
238
209
  var distance = 4000000;
239
210
  var clusterToAddTo = null;
240
211
  var position = marker.getPosition();
241
-
242
212
  for (var i = 0, cluster; cluster = this._clusters[i]; i++) {
243
213
  var center = cluster.getCenter();
244
-
245
214
  if (center) {
246
215
  var d = this._map.getDistance(center, marker.getPosition());
247
-
248
216
  if (d < distance) {
249
217
  distance = d;
250
218
  clusterToAddTo = cluster;
251
219
  }
252
220
  }
253
221
  }
254
-
255
222
  if (clusterToAddTo && clusterToAddTo.isMarkerInClusterBounds(marker)) {
256
223
  clusterToAddTo.addMarker(marker);
257
224
  } else {
258
225
  var cluster = new Cluster(this);
259
226
  cluster.addMarker(marker);
260
-
261
227
  this._clusters.push(cluster);
262
228
  }
263
229
  };
230
+
264
231
  /**
265
232
  * 清除上一次的聚合的结果
266
233
  * @return 无返回值。
267
234
  */
268
-
269
-
270
235
  MarkerClusterer.prototype._clearLastClusters = function () {
271
236
  for (var i = 0, cluster; cluster = this._clusters[i]; i++) {
272
237
  cluster.remove();
273
238
  }
274
-
275
239
  this._clusters = []; //置空Cluster数组
276
-
277
240
  this._removeMarkersFromCluster(); //把Marker的cluster标记设为false
278
-
279
241
  };
242
+
280
243
  /**
281
244
  * 清除某个聚合中的所有标记
282
245
  * @return 无返回值
283
246
  */
284
-
285
-
286
247
  MarkerClusterer.prototype._removeMarkersFromCluster = function () {
287
248
  for (var i = 0, marker; marker = this._markers[i]; i++) {
288
249
  marker.isInCluster = false;
289
250
  }
290
251
  };
252
+
291
253
  /**
292
254
  * 把所有的标记从地图上清除
293
255
  * @return 无返回值
294
256
  */
295
-
296
-
297
257
  MarkerClusterer.prototype._removeMarkersFromMap = function () {
298
258
  for (var i = 0, marker; marker = this._markers[i]; i++) {
299
259
  marker.isInCluster = false;
300
260
  tmplabel = marker.getLabel();
301
-
302
261
  this._map.removeOverlay(marker);
303
-
304
262
  marker.setLabel(tmplabel);
305
263
  }
306
264
  };
265
+
307
266
  /**
308
267
  * 删除单个标记
309
268
  * @param {BMap.Marker} marker 需要被删除的marker
310
269
  *
311
270
  * @return {Boolean} 删除成功返回true,否则返回false
312
271
  */
313
-
314
-
315
272
  MarkerClusterer.prototype._removeMarker = function (marker) {
316
273
  var index = indexOf(marker, this._markers);
317
-
318
274
  if (index === -1) {
319
275
  return false;
320
276
  }
321
-
322
277
  tmplabel = marker.getLabel();
323
-
324
278
  this._map.removeOverlay(marker);
325
-
326
279
  marker.setLabel(tmplabel);
327
-
328
280
  this._markers.splice(index, 1);
329
-
330
281
  return true;
331
282
  };
283
+
332
284
  /**
333
285
  * 删除单个标记
334
286
  * @param {BMap.Marker} marker 需要被删除的marker
335
287
  *
336
288
  * @return {Boolean} 删除成功返回true,否则返回false
337
289
  */
338
-
339
-
340
290
  MarkerClusterer.prototype.removeMarker = function (marker) {
341
291
  var success = this._removeMarker(marker);
342
-
343
292
  if (success) {
344
293
  this._clearLastClusters();
345
-
346
294
  this._createClusters();
347
295
  }
348
-
349
296
  return success;
350
297
  };
298
+
351
299
  /**
352
300
  * 删除一组标记
353
301
  * @param {Array<BMap.Marker>} markers 需要被删除的marker数组
354
302
  *
355
303
  * @return {Boolean} 删除成功返回true,否则返回false
356
304
  */
357
-
358
-
359
305
  MarkerClusterer.prototype.removeMarkers = function (markers) {
360
306
  var success = false;
361
-
362
307
  for (var i = 0; i < markers.length; i++) {
363
308
  var r = this._removeMarker(markers[i]);
364
-
365
309
  success = success || r;
366
310
  }
367
-
368
311
  if (success) {
369
312
  this._clearLastClusters();
370
-
371
313
  this._createClusters();
372
314
  }
373
-
374
315
  return success;
375
316
  };
317
+
376
318
  /**
377
319
  * 从地图上彻底清除所有的标记
378
320
  * @return 无返回值
379
321
  */
380
-
381
-
382
322
  MarkerClusterer.prototype.clearMarkers = function () {
383
323
  this._clearLastClusters();
384
-
385
324
  this._removeMarkersFromMap();
386
-
387
325
  this._markers = [];
388
326
  };
327
+
389
328
  /**
390
329
  * 重新生成,比如改变了属性等
391
330
  * @return 无返回值
392
331
  */
393
-
394
-
395
332
  MarkerClusterer.prototype._redraw = function () {
396
333
  this._clearLastClusters();
397
-
398
334
  this._createClusters();
399
335
  };
336
+
400
337
  /**
401
338
  * 获取网格大小
402
339
  * @return {Number} 网格大小
403
340
  */
404
-
405
-
406
341
  MarkerClusterer.prototype.getGridSize = function () {
407
342
  return this._gridSize;
408
343
  };
344
+
409
345
  /**
410
346
  * 设置网格大小
411
347
  * @param {Number} size 网格大小
412
348
  * @return 无返回值
413
349
  */
414
-
415
-
416
350
  MarkerClusterer.prototype.setGridSize = function (size) {
417
351
  this._gridSize = size;
418
-
419
352
  this._redraw();
420
353
  };
354
+
421
355
  /**
422
356
  * 获取聚合的最大缩放级别。
423
357
  * @return {Number} 聚合的最大缩放级别。
424
358
  */
425
-
426
-
427
359
  MarkerClusterer.prototype.getMaxZoom = function () {
428
360
  return this._maxZoom;
429
361
  };
362
+
430
363
  /**
431
364
  * 设置聚合的最大缩放级别
432
365
  * @param {Number} maxZoom 聚合的最大缩放级别
433
366
  * @return 无返回值
434
367
  */
435
-
436
-
437
368
  MarkerClusterer.prototype.setMaxZoom = function (maxZoom) {
438
369
  this._maxZoom = maxZoom;
439
-
440
370
  this._redraw();
441
371
  };
372
+
442
373
  /**
443
374
  * 获取聚合的样式风格集合
444
375
  * @return {Array<IconStyle>} 聚合的样式风格集合
445
376
  */
446
-
447
-
448
377
  MarkerClusterer.prototype.getStyles = function () {
449
378
  return this._styles;
450
379
  };
380
+
451
381
  /**
452
382
  * 设置聚合的样式风格集合
453
383
  * @param {Array<IconStyle>} styles 样式风格数组
454
384
  * @return 无返回值
455
385
  */
456
-
457
-
458
386
  MarkerClusterer.prototype.setStyles = function (styles) {
459
387
  this._styles = styles;
460
-
461
388
  this._redraw();
462
389
  };
390
+
463
391
  /**
464
392
  * 获取单个聚合的最小数量。
465
393
  * @return {Number} 单个聚合的最小数量。
466
394
  */
467
-
468
-
469
395
  MarkerClusterer.prototype.getMinClusterSize = function () {
470
396
  return this._minClusterSize;
471
397
  };
398
+
472
399
  /**
473
400
  * 设置单个聚合的最小数量。
474
401
  * @param {Number} size 单个聚合的最小数量。
475
402
  * @return 无返回值。
476
403
  */
477
-
478
-
479
404
  MarkerClusterer.prototype.setMinClusterSize = function (size) {
480
405
  this._minClusterSize = size;
481
-
482
406
  this._redraw();
483
407
  };
408
+
484
409
  /**
485
410
  * 获取单个聚合的落脚点是否是聚合内所有标记的平均中心。
486
411
  * @return {Boolean} true或false。
487
412
  */
488
-
489
-
490
413
  MarkerClusterer.prototype.isAverageCenter = function () {
491
414
  return this._isAverageCenter;
492
415
  };
416
+
493
417
  /**
494
418
  * 获取聚合的Map实例。
495
419
  * @return {Map} Map的示例。
496
420
  */
497
-
498
-
499
421
  MarkerClusterer.prototype.getMap = function () {
500
422
  return this._map;
501
423
  };
424
+
502
425
  /**
503
426
  * 获取所有的标记数组。
504
427
  * @return {Array<Marker>} 标记数组。
505
428
  */
506
-
507
-
508
429
  MarkerClusterer.prototype.getMarkers = function () {
509
430
  return this._markers;
510
431
  };
432
+
511
433
  /**
512
434
  * 获取聚合的总数量。
513
435
  * @return {Number} 聚合的总数量。
514
436
  */
515
-
516
-
517
437
  MarkerClusterer.prototype.getClustersCount = function () {
518
438
  var count = 0;
519
-
520
439
  for (var i = 0, cluster; cluster = this._clusters[i]; i++) {
521
440
  cluster.isReal() && count++;
522
441
  }
523
-
524
442
  return count;
525
443
  };
444
+
526
445
  /**
527
446
  * @ignore
528
447
  * Cluster
@@ -530,38 +449,32 @@ var BMapLib = window.BMapLib = BMapLib || {};
530
449
  * @constructor
531
450
  * @param {MarkerClusterer} markerClusterer 一个标记聚合器示例。
532
451
  */
533
-
534
-
535
452
  function Cluster(markerClusterer) {
536
453
  this._markerClusterer = markerClusterer;
537
454
  this._map = markerClusterer.getMap();
538
455
  this._minClusterSize = markerClusterer.getMinClusterSize();
539
456
  this._isAverageCenter = markerClusterer.isAverageCenter();
540
457
  this._center = null; //落脚位置
541
-
542
458
  this._markers = []; //这个Cluster中所包含的markers
543
-
544
459
  this._gridBounds = null; //以中心点为准,向四边扩大gridSize个像素的范围,也即网格范围
545
-
546
460
  this._isReal = false; //真的是个聚合
547
461
 
548
462
  this._clusterMarker = new BMapLib.TextIconOverlay(this._center, this._markers.length, {
549
463
  styles: this._markerClusterer.getStyles()
550
- }); //this._map.addOverlay(this._clusterMarker);
464
+ });
465
+ //this._map.addOverlay(this._clusterMarker);
551
466
  }
467
+
552
468
  /**
553
469
  * 向该聚合添加一个标记。
554
470
  * @param {Marker} marker 要添加的标记。
555
471
  * @return 无返回值。
556
472
  */
557
-
558
-
559
473
  Cluster.prototype.addMarker = function (marker) {
560
474
  if (this.isMarkerInCluster(marker)) {
561
475
  return false;
562
476
  } //也可用marker.isInCluster判断,外面判断OK,这里基本不会命中
563
477
 
564
-
565
478
  if (!this._center) {
566
479
  this._center = marker.getPosition();
567
480
  this.updateGridBounds(); //
@@ -573,40 +486,33 @@ var BMapLib = window.BMapLib = BMapLib || {};
573
486
  this._center = new BMap.Point(lng, lat);
574
487
  this.updateGridBounds();
575
488
  } //计算新的Center
576
-
577
489
  }
578
-
579
490
  marker.isInCluster = true;
580
-
581
491
  this._markers.push(marker);
582
492
  };
493
+
583
494
  /**
584
495
  * 进行dom操作
585
496
  * @return 无返回值
586
497
  */
587
-
588
-
589
498
  Cluster.prototype.render = function () {
590
499
  var len = this._markers.length;
591
-
592
500
  if (len < this._minClusterSize) {
593
501
  for (var i = 0; i < len; i++) {
594
502
  this._map.addOverlay(this._markers[i]);
595
503
  }
596
504
  } else {
597
505
  this._map.addOverlay(this._clusterMarker);
598
-
599
506
  this._isReal = true;
600
507
  this.updateClusterMarker();
601
508
  }
602
509
  };
510
+
603
511
  /**
604
512
  * 判断一个标记是否在该聚合中。
605
513
  * @param {Marker} marker 要判断的标记。
606
514
  * @return {Boolean} true或false。
607
515
  */
608
-
609
-
610
516
  Cluster.prototype.isMarkerInCluster = function (marker) {
611
517
  if (this._markers.indexOf) {
612
518
  return this._markers.indexOf(marker) != -1;
@@ -617,108 +523,86 @@ var BMapLib = window.BMapLib = BMapLib || {};
617
523
  }
618
524
  }
619
525
  }
620
-
621
526
  return false;
622
527
  };
528
+
623
529
  /**
624
530
  * 判断一个标记是否在该聚合网格范围中。
625
531
  * @param {Marker} marker 要判断的标记。
626
532
  * @return {Boolean} true或false。
627
533
  */
628
-
629
-
630
534
  Cluster.prototype.isMarkerInClusterBounds = function (marker) {
631
535
  return this._gridBounds.containsPoint(marker.getPosition());
632
536
  };
633
-
634
537
  Cluster.prototype.isReal = function (marker) {
635
538
  return this._isReal;
636
539
  };
540
+
637
541
  /**
638
542
  * 更新该聚合的网格范围。
639
543
  * @return 无返回值。
640
544
  */
641
-
642
-
643
545
  Cluster.prototype.updateGridBounds = function () {
644
546
  var bounds = new BMap.Bounds(this._center, this._center);
645
547
  this._gridBounds = getExtendedBounds(this._map, bounds, this._markerClusterer.getGridSize());
646
548
  };
549
+
647
550
  /**
648
551
  * 更新该聚合的显示样式,也即TextIconOverlay。
649
552
  * @return 无返回值。
650
553
  */
651
-
652
-
653
554
  Cluster.prototype.updateClusterMarker = function () {
654
555
  if (this._map.getZoom() > this._markerClusterer.getMaxZoom()) {
655
556
  this._clusterMarker && this._map.removeOverlay(this._clusterMarker);
656
-
657
557
  for (var i = 0, marker; marker = this._markers[i]; i++) {
658
558
  this._map.addOverlay(marker);
659
559
  }
660
-
661
560
  return;
662
561
  }
663
-
664
562
  if (this._markers.length < this._minClusterSize) {
665
563
  this._clusterMarker.hide();
666
-
667
564
  return;
668
565
  }
669
-
670
566
  this._clusterMarker.setPosition(this._center);
671
-
672
567
  this._clusterMarker.setText(this._markers.length);
673
-
674
568
  var thatMap = this._map;
675
569
  var thatBounds = this.getBounds();
676
-
677
570
  this._clusterMarker.addEventListener('click', function (event) {
678
571
  thatMap.setViewport(thatBounds);
679
572
  });
680
573
  };
574
+
681
575
  /**
682
576
  * 删除该聚合。
683
577
  * @return 无返回值。
684
578
  */
685
-
686
-
687
579
  Cluster.prototype.remove = function () {
688
580
  for (var i = 0, m; m = this._markers[i]; i++) {
689
581
  tmplabel = this._markers[i].getLabel();
690
582
  this._markers[i].getMap() && this._map.removeOverlay(this._markers[i]);
691
-
692
583
  this._markers[i].setLabel(tmplabel);
693
584
  } //清除散的标记点
694
-
695
-
696
585
  this._map.removeOverlay(this._clusterMarker);
697
-
698
586
  this._markers.length = 0;
699
587
  delete this._markers;
700
588
  };
589
+
701
590
  /**
702
591
  * 获取该聚合所包含的所有标记的最小外接矩形的范围。
703
592
  * @return {BMap.Bounds} 计算出的范围。
704
593
  */
705
-
706
-
707
594
  Cluster.prototype.getBounds = function () {
708
595
  var bounds = new BMap.Bounds(this._center, this._center);
709
-
710
596
  for (var i = 0, marker; marker = this._markers[i]; i++) {
711
597
  bounds.extend(marker.getPosition());
712
598
  }
713
-
714
599
  return bounds;
715
600
  };
601
+
716
602
  /**
717
603
  * 获取该聚合的落脚点。
718
604
  * @return {BMap.Point} 该聚合的落脚点。
719
605
  */
720
-
721
-
722
606
  Cluster.prototype.getCenter = function () {
723
607
  return this._center;
724
608
  };