@react-google-maps/marker-clusterer 2.3.0 → 2.6.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/dist/cjs.js +9 -5
- package/dist/cjs.js.map +1 -1
- package/dist/cjs.min.js +1 -1
- package/dist/cjs.min.js.map +1 -1
- package/dist/esm.js +9 -5
- package/dist/esm.js.map +1 -1
- package/dist/esm.min.js +1 -1
- package/dist/esm.min.js.map +1 -1
- package/dist/index.d.ts +8 -42
- package/dist/umd.js +944 -940
- package/dist/umd.js.map +1 -1
- package/dist/umd.min.js +1 -1
- package/dist/umd.min.js.map +1 -1
- package/package.json +18 -18
- package/src/Cluster.tsx +6 -2
- package/src/ClusterIcon.tsx +6 -5
package/dist/umd.js
CHANGED
|
@@ -1,948 +1,952 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}(this, (function (exports) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.markerClusterer = {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
7
|
+
var ClusterIcon = /** @class */ (function () {
|
|
8
|
+
function ClusterIcon(cluster, styles) {
|
|
9
|
+
cluster.getClusterer().extend(ClusterIcon, google.maps.OverlayView);
|
|
10
|
+
this.cluster = cluster;
|
|
11
|
+
this.clusterClassName = this.cluster.getClusterer().getClusterClass();
|
|
12
|
+
this.className = this.clusterClassName;
|
|
13
|
+
this.styles = styles;
|
|
14
|
+
this.center = undefined;
|
|
15
|
+
this.div = null;
|
|
16
|
+
this.sums = null;
|
|
17
|
+
this.visible = false;
|
|
18
|
+
this.boundsChangedListener = null;
|
|
19
|
+
this.url = '';
|
|
20
|
+
this.height = 0;
|
|
21
|
+
this.width = 0;
|
|
22
|
+
this.anchorText = [0, 0];
|
|
23
|
+
this.anchorIcon = [0, 0];
|
|
24
|
+
this.textColor = 'black';
|
|
25
|
+
this.textSize = 11;
|
|
26
|
+
this.textDecoration = 'none';
|
|
27
|
+
this.fontWeight = 'bold';
|
|
28
|
+
this.fontStyle = 'normal';
|
|
29
|
+
this.fontFamily = 'Arial,sans-serif';
|
|
30
|
+
this.backgroundPosition = '0 0';
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
this.setMap(cluster.getMap()); // Note: this causes onAdd to be called
|
|
34
|
+
}
|
|
35
|
+
ClusterIcon.prototype.onAdd = function () {
|
|
36
|
+
var _this = this;
|
|
37
|
+
var cMouseDownInCluster;
|
|
38
|
+
var cDraggingMapByCluster;
|
|
39
|
+
this.div = document.createElement('div');
|
|
40
|
+
this.div.className = this.className;
|
|
41
|
+
if (this.visible) {
|
|
42
|
+
this.show();
|
|
43
|
+
}
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
this.getPanes().overlayMouseTarget.appendChild(this.div);
|
|
47
|
+
// Fix for Issue 157
|
|
48
|
+
this.boundsChangedListener = google.maps.event.addListener(
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
this.getMap(), 'boundschanged', function boundsChanged() {
|
|
52
|
+
cDraggingMapByCluster = cMouseDownInCluster;
|
|
53
|
+
});
|
|
54
|
+
google.maps.event.addDomListener(this.div, 'mousedown', function onMouseDown() {
|
|
55
|
+
cMouseDownInCluster = true;
|
|
56
|
+
cDraggingMapByCluster = false;
|
|
57
|
+
});
|
|
58
|
+
// eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
|
|
59
|
+
google.maps.event.addDomListener(this.div, 'click',
|
|
60
|
+
// eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
|
|
61
|
+
function (event) {
|
|
62
|
+
cMouseDownInCluster = false;
|
|
63
|
+
if (!cDraggingMapByCluster) {
|
|
64
|
+
var markerClusterer_1 = _this.cluster.getClusterer();
|
|
65
|
+
/**
|
|
66
|
+
* This event is fired when a cluster marker is clicked.
|
|
67
|
+
* @name MarkerClusterer#click
|
|
68
|
+
* @param {Cluster} c The cluster that was clicked.
|
|
69
|
+
* @event
|
|
70
|
+
*/
|
|
71
|
+
google.maps.event.trigger(markerClusterer_1, 'click', _this.cluster);
|
|
72
|
+
google.maps.event.trigger(markerClusterer_1, 'clusterclick', _this.cluster); // deprecated name
|
|
73
|
+
// The default click handler follows. Disable it by setting
|
|
74
|
+
// the zoomOnClick property to false.
|
|
75
|
+
if (markerClusterer_1.getZoomOnClick()) {
|
|
76
|
+
// Zoom into the cluster.
|
|
77
|
+
var maxZoom_1 = markerClusterer_1.getMaxZoom();
|
|
78
|
+
var bounds_1 = _this.cluster.getBounds();
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
markerClusterer_1.getMap().fitBounds(bounds_1);
|
|
82
|
+
// There is a fix for Issue 170 here:
|
|
83
|
+
setTimeout(function timeout() {
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
85
|
+
// @ts-ignore
|
|
86
|
+
markerClusterer_1.getMap().fitBounds(bounds_1);
|
|
87
|
+
// Don't zoom beyond the max zoom level
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
if (maxZoom_1 !== null && markerClusterer_1.getMap().getZoom() > maxZoom_1) {
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
markerClusterer_1.getMap().setZoom(maxZoom_1 + 1);
|
|
94
|
+
}
|
|
95
|
+
}, 100);
|
|
96
|
+
}
|
|
97
|
+
// Prevent event propagation to the map:
|
|
98
|
+
event.cancelBubble = true;
|
|
99
|
+
if (event.stopPropagation) {
|
|
100
|
+
event.stopPropagation();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
google.maps.event.addDomListener(this.div, 'mouseover',
|
|
105
|
+
// eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
|
|
106
|
+
function () {
|
|
107
|
+
/**
|
|
108
|
+
* This event is fired when the mouse moves over a cluster marker.
|
|
109
|
+
* @name MarkerClusterer#mouseover
|
|
110
|
+
* @param {Cluster} c The cluster that the mouse moved over.
|
|
111
|
+
* @event
|
|
112
|
+
*/
|
|
113
|
+
google.maps.event.trigger(_this.cluster.getClusterer(), 'mouseover', _this.cluster);
|
|
114
|
+
});
|
|
115
|
+
// eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
|
|
116
|
+
google.maps.event.addDomListener(this.div, 'mouseout',
|
|
117
|
+
// eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
|
|
118
|
+
function () {
|
|
119
|
+
/**
|
|
120
|
+
* This event is fired when the mouse moves out of a cluster marker.
|
|
121
|
+
* @name MarkerClusterer#mouseout
|
|
122
|
+
* @param {Cluster} c The cluster that the mouse moved out of.
|
|
123
|
+
* @event
|
|
124
|
+
*/
|
|
125
|
+
google.maps.event.trigger(_this.cluster.getClusterer(), 'mouseout', _this.cluster);
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
ClusterIcon.prototype.onRemove = function () {
|
|
129
|
+
if (this.div && this.div.parentNode) {
|
|
130
|
+
this.hide();
|
|
131
|
+
if (this.boundsChangedListener !== null) {
|
|
132
|
+
google.maps.event.removeListener(this.boundsChangedListener);
|
|
133
|
+
}
|
|
134
|
+
google.maps.event.clearInstanceListeners(this.div);
|
|
135
|
+
this.div.parentNode.removeChild(this.div);
|
|
136
|
+
this.div = null;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
ClusterIcon.prototype.draw = function () {
|
|
140
|
+
if (this.visible && this.div !== null && this.center) {
|
|
141
|
+
var _a = this.getPosFromLatLng(this.center), x = _a.x, y = _a.y;
|
|
142
|
+
this.div.style.top = y + 'px';
|
|
143
|
+
this.div.style.left = x + 'px';
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
ClusterIcon.prototype.hide = function () {
|
|
147
|
+
if (this.div) {
|
|
148
|
+
this.div.style.display = 'none';
|
|
149
|
+
}
|
|
150
|
+
this.visible = false;
|
|
151
|
+
};
|
|
152
|
+
ClusterIcon.prototype.show = function () {
|
|
153
|
+
if (this.div && this.center) {
|
|
154
|
+
var img = '', divTitle = '';
|
|
155
|
+
// NOTE: values must be specified in px units
|
|
156
|
+
var bp = this.backgroundPosition.split(' ');
|
|
157
|
+
var spriteH = parseInt(bp[0].replace(/^\s+|\s+$/g, ''), 10);
|
|
158
|
+
var spriteV = parseInt(bp[1].replace(/^\s+|\s+$/g, ''), 10);
|
|
159
|
+
var pos = this.getPosFromLatLng(this.center);
|
|
160
|
+
if (this.sums === null || typeof this.sums.title === 'undefined' || this.sums.title === '') {
|
|
161
|
+
divTitle = this.cluster.getClusterer().getTitle();
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
divTitle = this.sums.title;
|
|
165
|
+
}
|
|
166
|
+
this.div.style.cssText = this.createCss(pos);
|
|
167
|
+
img =
|
|
168
|
+
"<img alt='" +
|
|
169
|
+
divTitle +
|
|
170
|
+
"' src='" +
|
|
171
|
+
this.url +
|
|
172
|
+
"' style='position: absolute; top: " +
|
|
173
|
+
spriteV +
|
|
174
|
+
'px; left: ' +
|
|
175
|
+
spriteH +
|
|
176
|
+
'px; ';
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
178
|
+
//@ts-ignore
|
|
179
|
+
if (!this.cluster.getClusterer().enableRetinaIcons) {
|
|
180
|
+
img +=
|
|
181
|
+
'clip: rect(' +
|
|
182
|
+
-1 * spriteV +
|
|
183
|
+
'px, ' +
|
|
184
|
+
(-1 * spriteH + this.width) +
|
|
185
|
+
'px, ' +
|
|
186
|
+
(-1 * spriteV + this.height) +
|
|
187
|
+
'px, ' +
|
|
188
|
+
-1 * spriteH +
|
|
189
|
+
'px);';
|
|
190
|
+
}
|
|
191
|
+
img += "'>";
|
|
192
|
+
this.div.innerHTML =
|
|
193
|
+
img +
|
|
194
|
+
"<div style='" +
|
|
195
|
+
'position: absolute;' +
|
|
196
|
+
'top: ' +
|
|
197
|
+
this.anchorText[0] +
|
|
198
|
+
'px;' +
|
|
199
|
+
'left: ' +
|
|
200
|
+
this.anchorText[1] +
|
|
201
|
+
'px;' +
|
|
202
|
+
'color: ' +
|
|
203
|
+
this.textColor +
|
|
204
|
+
';' +
|
|
205
|
+
'font-size: ' +
|
|
206
|
+
this.textSize +
|
|
207
|
+
'px;' +
|
|
208
|
+
'font-family: ' +
|
|
209
|
+
this.fontFamily +
|
|
210
|
+
';' +
|
|
211
|
+
'font-weight: ' +
|
|
212
|
+
this.fontWeight +
|
|
213
|
+
';' +
|
|
214
|
+
'font-style: ' +
|
|
215
|
+
this.fontStyle +
|
|
216
|
+
';' +
|
|
217
|
+
'text-decoration: ' +
|
|
218
|
+
this.textDecoration +
|
|
219
|
+
';' +
|
|
220
|
+
'text-align: center;' +
|
|
221
|
+
'width: ' +
|
|
222
|
+
this.width +
|
|
223
|
+
'px;' +
|
|
224
|
+
'line-height:' +
|
|
225
|
+
this.height +
|
|
226
|
+
'px;' +
|
|
227
|
+
"'>" +
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
229
|
+
// @ts-ignore
|
|
230
|
+
this.sums.text +
|
|
231
|
+
'</div>';
|
|
232
|
+
this.div.title = divTitle;
|
|
233
|
+
this.div.style.display = '';
|
|
234
|
+
}
|
|
235
|
+
this.visible = true;
|
|
236
|
+
};
|
|
237
|
+
ClusterIcon.prototype.useStyle = function (sums) {
|
|
238
|
+
this.sums = sums;
|
|
239
|
+
var styles = this.cluster.getClusterer().getStyles();
|
|
240
|
+
var style = styles[Math.min(styles.length - 1, Math.max(0, sums.index - 1))];
|
|
241
|
+
this.url = style.url;
|
|
242
|
+
this.height = style.height;
|
|
243
|
+
this.width = style.width;
|
|
244
|
+
if (style.className)
|
|
245
|
+
this.className = this.clusterClassName + " " + style.className;
|
|
246
|
+
this.anchorText = style.anchorText || [0, 0];
|
|
247
|
+
this.anchorIcon = style.anchorIcon || [this.height / 2, this.width / 2];
|
|
248
|
+
this.textColor = style.textColor || 'black';
|
|
249
|
+
this.textSize = style.textSize || 11;
|
|
250
|
+
this.textDecoration = style.textDecoration || 'none';
|
|
251
|
+
this.fontWeight = style.fontWeight || 'bold';
|
|
252
|
+
this.fontStyle = style.fontStyle || 'normal';
|
|
253
|
+
this.fontFamily = style.fontFamily || 'Arial,sans-serif';
|
|
254
|
+
this.backgroundPosition = style.backgroundPosition || '0 0';
|
|
255
|
+
};
|
|
256
|
+
ClusterIcon.prototype.setCenter = function (center) {
|
|
257
|
+
this.center = center;
|
|
258
|
+
};
|
|
259
|
+
ClusterIcon.prototype.createCss = function (pos) {
|
|
260
|
+
var style = [];
|
|
261
|
+
style.push('cursor: pointer;');
|
|
262
|
+
style.push('position: absolute; top: ' + pos.y + 'px; left: ' + pos.x + 'px;');
|
|
263
|
+
style.push('width: ' + this.width + 'px; height: ' + this.height + 'px;');
|
|
264
|
+
return style.join('');
|
|
265
|
+
};
|
|
266
|
+
ClusterIcon.prototype.getPosFromLatLng = function (latlng) {
|
|
267
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
268
|
+
// @ts-ignore
|
|
269
|
+
var pos = this.getProjection().fromLatLngToDivPixel(latlng);
|
|
270
|
+
pos.x -= this.anchorIcon[1];
|
|
271
|
+
pos.y -= this.anchorIcon[0];
|
|
272
|
+
// pos.x = pos.x
|
|
273
|
+
// pos.y = pos.y
|
|
274
|
+
return pos;
|
|
275
|
+
};
|
|
276
|
+
return ClusterIcon;
|
|
277
|
+
}());
|
|
276
278
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
279
|
+
var Cluster = /** @class */ (function () {
|
|
280
|
+
function Cluster(markerClusterer) {
|
|
281
|
+
this.markerClusterer = markerClusterer;
|
|
282
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
283
|
+
// @ts-ignore
|
|
284
|
+
this.map = this.markerClusterer.getMap();
|
|
285
|
+
this.gridSize = this.markerClusterer.getGridSize();
|
|
286
|
+
this.minClusterSize = this.markerClusterer.getMinimumClusterSize();
|
|
287
|
+
this.averageCenter = this.markerClusterer.getAverageCenter();
|
|
288
|
+
this.markers = [];
|
|
289
|
+
this.center = undefined;
|
|
290
|
+
this.bounds = null;
|
|
291
|
+
this.clusterIcon = new ClusterIcon(this, this.markerClusterer.getStyles());
|
|
292
|
+
}
|
|
293
|
+
Cluster.prototype.getSize = function () {
|
|
294
|
+
return this.markers.length;
|
|
295
|
+
};
|
|
296
|
+
Cluster.prototype.getMarkers = function () {
|
|
297
|
+
return this.markers;
|
|
298
|
+
};
|
|
299
|
+
Cluster.prototype.getCenter = function () {
|
|
300
|
+
return this.center;
|
|
301
|
+
};
|
|
302
|
+
Cluster.prototype.getMap = function () {
|
|
303
|
+
return this.map;
|
|
304
|
+
};
|
|
305
|
+
Cluster.prototype.getClusterer = function () {
|
|
306
|
+
return this.markerClusterer;
|
|
307
|
+
};
|
|
308
|
+
Cluster.prototype.getBounds = function () {
|
|
309
|
+
var bounds = new google.maps.LatLngBounds(this.center, this.center);
|
|
310
|
+
var markers = this.getMarkers();
|
|
311
|
+
for (var i = 0; i < markers.length; i++) {
|
|
312
|
+
var position = markers[i].getPosition();
|
|
313
|
+
if (position) {
|
|
314
|
+
bounds.extend(position);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return bounds;
|
|
318
|
+
};
|
|
319
|
+
Cluster.prototype.remove = function () {
|
|
320
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
321
|
+
// @ts-ignore
|
|
322
|
+
this.clusterIcon.setMap(null);
|
|
323
|
+
this.markers = [];
|
|
324
|
+
// @ts-ignore
|
|
325
|
+
delete this.markers;
|
|
326
|
+
};
|
|
327
|
+
Cluster.prototype.addMarker = function (marker) {
|
|
328
|
+
if (this.isMarkerAlreadyAdded(marker)) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
if (!this.center) {
|
|
332
|
+
var position = marker.getPosition();
|
|
333
|
+
if (position) {
|
|
334
|
+
this.center = position;
|
|
335
|
+
this.calculateBounds();
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
if (this.averageCenter) {
|
|
340
|
+
var position = marker.getPosition();
|
|
341
|
+
if (position) {
|
|
342
|
+
var length_1 = this.markers.length + 1;
|
|
343
|
+
this.center = new google.maps.LatLng((this.center.lat() * (length_1 - 1) + position.lat()) / length_1, (this.center.lng() * (length_1 - 1) + position.lng()) / length_1);
|
|
344
|
+
this.calculateBounds();
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
marker.isAdded = true;
|
|
349
|
+
this.markers.push(marker);
|
|
350
|
+
var mCount = this.markers.length;
|
|
351
|
+
var maxZoom = this.markerClusterer.getMaxZoom();
|
|
352
|
+
var zoom = this.map.getZoom();
|
|
353
|
+
if (maxZoom !== null && typeof zoom !== 'undefined' && zoom > maxZoom) {
|
|
354
|
+
// Zoomed in past max zoom, so show the marker.
|
|
355
|
+
if (marker.getMap() !== this.map) {
|
|
356
|
+
marker.setMap(this.map);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
else if (mCount < this.minClusterSize) {
|
|
360
|
+
// Min cluster size not reached so show the marker.
|
|
361
|
+
if (marker.getMap() !== this.map) {
|
|
362
|
+
marker.setMap(this.map);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
else if (mCount === this.minClusterSize) {
|
|
366
|
+
// Hide the markers that were showing.
|
|
367
|
+
for (var i = 0; i < mCount; i++) {
|
|
368
|
+
this.markers[i].setMap(null);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
marker.setMap(null);
|
|
373
|
+
}
|
|
374
|
+
return true;
|
|
375
|
+
};
|
|
376
|
+
Cluster.prototype.isMarkerInClusterBounds = function (marker) {
|
|
377
|
+
if (this.bounds !== null) {
|
|
378
|
+
var position = marker.getPosition();
|
|
379
|
+
if (position) {
|
|
380
|
+
return this.bounds.contains(position);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return false;
|
|
384
|
+
};
|
|
385
|
+
Cluster.prototype.calculateBounds = function () {
|
|
386
|
+
this.bounds = this.markerClusterer.getExtendedBounds(new google.maps.LatLngBounds(this.center, this.center));
|
|
387
|
+
};
|
|
388
|
+
Cluster.prototype.updateIcon = function () {
|
|
389
|
+
var mCount = this.markers.length;
|
|
390
|
+
var maxZoom = this.markerClusterer.getMaxZoom();
|
|
391
|
+
var zoom = this.map.getZoom();
|
|
392
|
+
if (maxZoom !== null && typeof zoom !== 'undefined' && zoom > maxZoom) {
|
|
393
|
+
this.clusterIcon.hide();
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
if (mCount < this.minClusterSize) {
|
|
397
|
+
// Min cluster size not yet reached.
|
|
398
|
+
this.clusterIcon.hide();
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
if (this.center) {
|
|
402
|
+
this.clusterIcon.setCenter(this.center);
|
|
403
|
+
}
|
|
404
|
+
this.clusterIcon.useStyle(this.markerClusterer.getCalculator()(this.markers, this.markerClusterer.getStyles().length));
|
|
405
|
+
this.clusterIcon.show();
|
|
406
|
+
};
|
|
407
|
+
Cluster.prototype.isMarkerAlreadyAdded = function (marker) {
|
|
408
|
+
if (this.markers.includes) {
|
|
409
|
+
return this.markers.includes(marker);
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
for (var i = 0; i < this.markers.length; i++) {
|
|
413
|
+
if (marker === this.markers[i]) {
|
|
414
|
+
return true;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return false;
|
|
419
|
+
};
|
|
420
|
+
return Cluster;
|
|
421
|
+
}());
|
|
418
422
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
423
|
+
/* global google */
|
|
424
|
+
/**
|
|
425
|
+
* Supports up to 9007199254740991 (Number.MAX_SAFE_INTEGER) markers
|
|
426
|
+
* which is not a problem as max array length is 4294967296 (2**32)
|
|
427
|
+
*/
|
|
428
|
+
var CALCULATOR = function CALCULATOR(markers, numStyles) {
|
|
429
|
+
var count = markers.length;
|
|
430
|
+
var numberOfDigits = count.toString().length;
|
|
431
|
+
var index = Math.min(numberOfDigits, numStyles);
|
|
432
|
+
return {
|
|
433
|
+
text: count.toString(),
|
|
434
|
+
index: index,
|
|
435
|
+
title: '',
|
|
436
|
+
};
|
|
437
|
+
};
|
|
438
|
+
var BATCH_SIZE = 2000;
|
|
439
|
+
var BATCH_SIZE_IE = 500;
|
|
440
|
+
var IMAGE_PATH = 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m';
|
|
441
|
+
var IMAGE_EXTENSION = 'png';
|
|
442
|
+
var IMAGE_SIZES = [53, 56, 66, 78, 90];
|
|
443
|
+
var CLUSTERER_CLASS = 'cluster';
|
|
444
|
+
var Clusterer = /** @class */ (function () {
|
|
445
|
+
function Clusterer(map, optMarkers, optOptions) {
|
|
446
|
+
if (optMarkers === void 0) { optMarkers = []; }
|
|
447
|
+
if (optOptions === void 0) { optOptions = {}; }
|
|
448
|
+
this.extend(Clusterer, google.maps.OverlayView);
|
|
449
|
+
this.markers = [];
|
|
450
|
+
this.clusters = [];
|
|
451
|
+
this.listeners = [];
|
|
452
|
+
this.activeMap = null;
|
|
453
|
+
this.ready = false;
|
|
454
|
+
this.gridSize = optOptions.gridSize || 60;
|
|
455
|
+
this.minClusterSize = optOptions.minimumClusterSize || 2;
|
|
456
|
+
this.maxZoom = optOptions.maxZoom || null;
|
|
457
|
+
this.styles = optOptions.styles || [];
|
|
458
|
+
this.title = optOptions.title || '';
|
|
459
|
+
this.zoomOnClick = true;
|
|
460
|
+
if (optOptions.zoomOnClick !== undefined) {
|
|
461
|
+
this.zoomOnClick = optOptions.zoomOnClick;
|
|
462
|
+
}
|
|
463
|
+
this.averageCenter = false;
|
|
464
|
+
if (optOptions.averageCenter !== undefined) {
|
|
465
|
+
this.averageCenter = optOptions.averageCenter;
|
|
466
|
+
}
|
|
467
|
+
this.ignoreHidden = false;
|
|
468
|
+
if (optOptions.ignoreHidden !== undefined) {
|
|
469
|
+
this.ignoreHidden = optOptions.ignoreHidden;
|
|
470
|
+
}
|
|
471
|
+
this.enableRetinaIcons = false;
|
|
472
|
+
if (optOptions.enableRetinaIcons !== undefined) {
|
|
473
|
+
this.enableRetinaIcons = optOptions.enableRetinaIcons;
|
|
474
|
+
}
|
|
475
|
+
this.imagePath = optOptions.imagePath || IMAGE_PATH;
|
|
476
|
+
this.imageExtension = optOptions.imageExtension || IMAGE_EXTENSION;
|
|
477
|
+
this.imageSizes = optOptions.imageSizes || IMAGE_SIZES;
|
|
478
|
+
this.calculator = optOptions.calculator || CALCULATOR;
|
|
479
|
+
this.batchSize = optOptions.batchSize || BATCH_SIZE;
|
|
480
|
+
this.batchSizeIE = optOptions.batchSizeIE || BATCH_SIZE_IE;
|
|
481
|
+
this.clusterClass = optOptions.clusterClass || CLUSTERER_CLASS;
|
|
482
|
+
if (navigator.userAgent.toLowerCase().indexOf('msie') !== -1) {
|
|
483
|
+
// Try to avoid IE timeout when processing a huge number of markers:
|
|
484
|
+
this.batchSize = this.batchSizeIE;
|
|
485
|
+
}
|
|
486
|
+
this.timerRefStatic = null;
|
|
487
|
+
this.setupStyles();
|
|
488
|
+
this.addMarkers(optMarkers, true);
|
|
489
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
490
|
+
// @ts-ignore
|
|
491
|
+
this.setMap(map); // Note: this causes onAdd to be called
|
|
492
|
+
}
|
|
493
|
+
Clusterer.prototype.onAdd = function () {
|
|
494
|
+
var _this = this;
|
|
495
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
496
|
+
// @ts-ignore
|
|
497
|
+
this.activeMap = this.getMap();
|
|
498
|
+
this.ready = true;
|
|
499
|
+
this.repaint();
|
|
500
|
+
// Add the map event listeners
|
|
501
|
+
this.listeners = [
|
|
502
|
+
google.maps.event.addListener(
|
|
503
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
504
|
+
// @ts-ignore
|
|
505
|
+
this.getMap(), 'zoom_changed',
|
|
506
|
+
// eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
|
|
507
|
+
function () {
|
|
508
|
+
_this.resetViewport(false);
|
|
509
|
+
// Workaround for this Google bug: when map is at level 0 and "-" of
|
|
510
|
+
// zoom slider is clicked, a "zoom_changed" event is fired even though
|
|
511
|
+
// the map doesn't zoom out any further. In this situation, no "idle"
|
|
512
|
+
// event is triggered so the cluster markers that have been removed
|
|
513
|
+
// do not get redrawn. Same goes for a zoom in at maxZoom.
|
|
514
|
+
if (
|
|
515
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
516
|
+
// @ts-ignore
|
|
517
|
+
_this.getMap().getZoom() === (_this.get('minZoom') || 0) ||
|
|
518
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
519
|
+
// @ts-ignore
|
|
520
|
+
_this.getMap().getZoom() === _this.get('maxZoom')) {
|
|
521
|
+
google.maps.event.trigger(_this, 'idle');
|
|
522
|
+
}
|
|
523
|
+
}),
|
|
524
|
+
google.maps.event.addListener(
|
|
525
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
526
|
+
// @ts-ignore
|
|
527
|
+
this.getMap(), 'idle',
|
|
528
|
+
// eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
|
|
529
|
+
function () {
|
|
530
|
+
_this.redraw();
|
|
531
|
+
}),
|
|
532
|
+
];
|
|
533
|
+
};
|
|
534
|
+
// eslint-disable-next-line @getify/proper-arrows/this
|
|
535
|
+
Clusterer.prototype.onRemove = function () {
|
|
536
|
+
// Put all the managed markers back on the map:
|
|
537
|
+
for (var i = 0; i < this.markers.length; i++) {
|
|
538
|
+
if (this.markers[i].getMap() !== this.activeMap) {
|
|
539
|
+
this.markers[i].setMap(this.activeMap);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
// Remove all clusters:
|
|
543
|
+
for (var i = 0; i < this.clusters.length; i++) {
|
|
544
|
+
this.clusters[i].remove();
|
|
545
|
+
}
|
|
546
|
+
this.clusters = [];
|
|
547
|
+
// Remove map event listeners:
|
|
548
|
+
for (var i = 0; i < this.listeners.length; i++) {
|
|
549
|
+
google.maps.event.removeListener(this.listeners[i]);
|
|
550
|
+
}
|
|
551
|
+
this.listeners = [];
|
|
552
|
+
this.activeMap = null;
|
|
553
|
+
this.ready = false;
|
|
554
|
+
};
|
|
555
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
556
|
+
Clusterer.prototype.draw = function () { };
|
|
557
|
+
Clusterer.prototype.setupStyles = function () {
|
|
558
|
+
if (this.styles.length > 0) {
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
for (var i = 0; i < this.imageSizes.length; i++) {
|
|
562
|
+
this.styles.push({
|
|
563
|
+
url: this.imagePath + (i + 1) + '.' + this.imageExtension,
|
|
564
|
+
height: this.imageSizes[i],
|
|
565
|
+
width: this.imageSizes[i],
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
Clusterer.prototype.fitMapToMarkers = function () {
|
|
570
|
+
var markers = this.getMarkers();
|
|
571
|
+
var bounds = new google.maps.LatLngBounds();
|
|
572
|
+
for (var i = 0; i < markers.length; i++) {
|
|
573
|
+
var position = markers[i].getPosition();
|
|
574
|
+
if (position) {
|
|
575
|
+
bounds.extend(position);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
579
|
+
// @ts-ignore
|
|
580
|
+
this.getMap().fitBounds(bounds);
|
|
581
|
+
};
|
|
582
|
+
Clusterer.prototype.getGridSize = function () {
|
|
583
|
+
return this.gridSize;
|
|
584
|
+
};
|
|
585
|
+
Clusterer.prototype.setGridSize = function (gridSize) {
|
|
586
|
+
this.gridSize = gridSize;
|
|
587
|
+
};
|
|
588
|
+
Clusterer.prototype.getMinimumClusterSize = function () {
|
|
589
|
+
return this.minClusterSize;
|
|
590
|
+
};
|
|
591
|
+
Clusterer.prototype.setMinimumClusterSize = function (minimumClusterSize) {
|
|
592
|
+
this.minClusterSize = minimumClusterSize;
|
|
593
|
+
};
|
|
594
|
+
Clusterer.prototype.getMaxZoom = function () {
|
|
595
|
+
return this.maxZoom;
|
|
596
|
+
};
|
|
597
|
+
Clusterer.prototype.setMaxZoom = function (maxZoom) {
|
|
598
|
+
this.maxZoom = maxZoom;
|
|
599
|
+
};
|
|
600
|
+
Clusterer.prototype.getStyles = function () {
|
|
601
|
+
return this.styles;
|
|
602
|
+
};
|
|
603
|
+
Clusterer.prototype.setStyles = function (styles) {
|
|
604
|
+
this.styles = styles;
|
|
605
|
+
};
|
|
606
|
+
Clusterer.prototype.getTitle = function () {
|
|
607
|
+
return this.title;
|
|
608
|
+
};
|
|
609
|
+
Clusterer.prototype.setTitle = function (title) {
|
|
610
|
+
this.title = title;
|
|
611
|
+
};
|
|
612
|
+
Clusterer.prototype.getZoomOnClick = function () {
|
|
613
|
+
return this.zoomOnClick;
|
|
614
|
+
};
|
|
615
|
+
Clusterer.prototype.setZoomOnClick = function (zoomOnClick) {
|
|
616
|
+
this.zoomOnClick = zoomOnClick;
|
|
617
|
+
};
|
|
618
|
+
Clusterer.prototype.getAverageCenter = function () {
|
|
619
|
+
return this.averageCenter;
|
|
620
|
+
};
|
|
621
|
+
Clusterer.prototype.setAverageCenter = function (averageCenter) {
|
|
622
|
+
this.averageCenter = averageCenter;
|
|
623
|
+
};
|
|
624
|
+
Clusterer.prototype.getIgnoreHidden = function () {
|
|
625
|
+
return this.ignoreHidden;
|
|
626
|
+
};
|
|
627
|
+
Clusterer.prototype.setIgnoreHidden = function (ignoreHidden) {
|
|
628
|
+
this.ignoreHidden = ignoreHidden;
|
|
629
|
+
};
|
|
630
|
+
Clusterer.prototype.getEnableRetinaIcons = function () {
|
|
631
|
+
return this.enableRetinaIcons;
|
|
632
|
+
};
|
|
633
|
+
Clusterer.prototype.setEnableRetinaIcons = function (enableRetinaIcons) {
|
|
634
|
+
this.enableRetinaIcons = enableRetinaIcons;
|
|
635
|
+
};
|
|
636
|
+
Clusterer.prototype.getImageExtension = function () {
|
|
637
|
+
return this.imageExtension;
|
|
638
|
+
};
|
|
639
|
+
Clusterer.prototype.setImageExtension = function (imageExtension) {
|
|
640
|
+
this.imageExtension = imageExtension;
|
|
641
|
+
};
|
|
642
|
+
Clusterer.prototype.getImagePath = function () {
|
|
643
|
+
return this.imagePath;
|
|
644
|
+
};
|
|
645
|
+
Clusterer.prototype.setImagePath = function (imagePath) {
|
|
646
|
+
this.imagePath = imagePath;
|
|
647
|
+
};
|
|
648
|
+
Clusterer.prototype.getImageSizes = function () {
|
|
649
|
+
return this.imageSizes;
|
|
650
|
+
};
|
|
651
|
+
Clusterer.prototype.setImageSizes = function (imageSizes) {
|
|
652
|
+
this.imageSizes = imageSizes;
|
|
653
|
+
};
|
|
654
|
+
Clusterer.prototype.getCalculator = function () {
|
|
655
|
+
return this.calculator;
|
|
656
|
+
};
|
|
657
|
+
Clusterer.prototype.setCalculator = function (calculator) {
|
|
658
|
+
this.calculator = calculator;
|
|
659
|
+
};
|
|
660
|
+
Clusterer.prototype.getBatchSizeIE = function () {
|
|
661
|
+
return this.batchSizeIE;
|
|
662
|
+
};
|
|
663
|
+
Clusterer.prototype.setBatchSizeIE = function (batchSizeIE) {
|
|
664
|
+
this.batchSizeIE = batchSizeIE;
|
|
665
|
+
};
|
|
666
|
+
Clusterer.prototype.getClusterClass = function () {
|
|
667
|
+
return this.clusterClass;
|
|
668
|
+
};
|
|
669
|
+
Clusterer.prototype.setClusterClass = function (clusterClass) {
|
|
670
|
+
this.clusterClass = clusterClass;
|
|
671
|
+
};
|
|
672
|
+
Clusterer.prototype.getMarkers = function () {
|
|
673
|
+
return this.markers;
|
|
674
|
+
};
|
|
675
|
+
Clusterer.prototype.getTotalMarkers = function () {
|
|
676
|
+
return this.markers.length;
|
|
677
|
+
};
|
|
678
|
+
Clusterer.prototype.getClusters = function () {
|
|
679
|
+
return this.clusters;
|
|
680
|
+
};
|
|
681
|
+
Clusterer.prototype.getTotalClusters = function () {
|
|
682
|
+
return this.clusters.length;
|
|
683
|
+
};
|
|
684
|
+
Clusterer.prototype.addMarker = function (marker, optNoDraw) {
|
|
685
|
+
this.pushMarkerTo(marker);
|
|
686
|
+
if (!optNoDraw) {
|
|
687
|
+
this.redraw();
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
Clusterer.prototype.addMarkers = function (markers, optNoDraw) {
|
|
691
|
+
for (var key in markers) {
|
|
692
|
+
if (markers.hasOwnProperty(key)) {
|
|
693
|
+
this.pushMarkerTo(markers[key]);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
if (!optNoDraw) {
|
|
697
|
+
this.redraw();
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
Clusterer.prototype.pushMarkerTo = function (marker) {
|
|
701
|
+
var _this = this;
|
|
702
|
+
// If the marker is draggable add a listener so we can update the clusters on the dragend:
|
|
703
|
+
if (marker.getDraggable()) {
|
|
704
|
+
// eslint-disable-next-line @getify/proper-arrows/name, @getify/proper-arrows/this
|
|
705
|
+
google.maps.event.addListener(marker, 'dragend', function () {
|
|
706
|
+
if (_this.ready) {
|
|
707
|
+
marker.isAdded = false;
|
|
708
|
+
_this.repaint();
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
marker.isAdded = false;
|
|
713
|
+
this.markers.push(marker);
|
|
714
|
+
};
|
|
715
|
+
Clusterer.prototype.removeMarker_ = function (marker) {
|
|
716
|
+
var index = -1;
|
|
717
|
+
if (this.markers.indexOf) {
|
|
718
|
+
index = this.markers.indexOf(marker);
|
|
719
|
+
}
|
|
720
|
+
else {
|
|
721
|
+
for (var i = 0; i < this.markers.length; i++) {
|
|
722
|
+
if (marker === this.markers[i]) {
|
|
723
|
+
index = i;
|
|
724
|
+
break;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
if (index === -1) {
|
|
729
|
+
// Marker is not in our list of markers, so do nothing:
|
|
730
|
+
return false;
|
|
731
|
+
}
|
|
732
|
+
marker.setMap(null);
|
|
733
|
+
this.markers.splice(index, 1); // Remove the marker from the list of managed markers
|
|
734
|
+
return true;
|
|
735
|
+
};
|
|
736
|
+
Clusterer.prototype.removeMarker = function (marker, optNoDraw) {
|
|
737
|
+
var removed = this.removeMarker_(marker);
|
|
738
|
+
if (!optNoDraw && removed) {
|
|
739
|
+
this.repaint();
|
|
740
|
+
}
|
|
741
|
+
return removed;
|
|
742
|
+
};
|
|
743
|
+
Clusterer.prototype.removeMarkers = function (markers, optNoDraw) {
|
|
744
|
+
var removed = false;
|
|
745
|
+
for (var i = 0; i < markers.length; i++) {
|
|
746
|
+
removed = removed || this.removeMarker_(markers[i]);
|
|
747
|
+
}
|
|
748
|
+
if (!optNoDraw && removed) {
|
|
749
|
+
this.repaint();
|
|
750
|
+
}
|
|
751
|
+
return removed;
|
|
752
|
+
};
|
|
753
|
+
Clusterer.prototype.clearMarkers = function () {
|
|
754
|
+
this.resetViewport(true);
|
|
755
|
+
this.markers = [];
|
|
756
|
+
};
|
|
757
|
+
Clusterer.prototype.repaint = function () {
|
|
758
|
+
var oldClusters = this.clusters.slice();
|
|
759
|
+
this.clusters = [];
|
|
760
|
+
this.resetViewport(false);
|
|
761
|
+
this.redraw();
|
|
762
|
+
// Remove the old clusters.
|
|
763
|
+
// Do it in a timeout to prevent blinking effect.
|
|
764
|
+
setTimeout(function timeout() {
|
|
765
|
+
for (var i = 0; i < oldClusters.length; i++) {
|
|
766
|
+
oldClusters[i].remove();
|
|
767
|
+
}
|
|
768
|
+
}, 0);
|
|
769
|
+
};
|
|
770
|
+
Clusterer.prototype.getExtendedBounds = function (bounds) {
|
|
771
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
772
|
+
// @ts-ignore
|
|
773
|
+
var projection = this.getProjection();
|
|
774
|
+
// Convert the points to pixels and the extend out by the grid size.
|
|
775
|
+
var trPix = projection.fromLatLngToDivPixel(
|
|
776
|
+
// Turn the bounds into latlng.
|
|
777
|
+
new google.maps.LatLng(bounds.getNorthEast().lat(), bounds.getNorthEast().lng()));
|
|
778
|
+
trPix.x += this.gridSize;
|
|
779
|
+
trPix.y -= this.gridSize;
|
|
780
|
+
var blPix = projection.fromLatLngToDivPixel(
|
|
781
|
+
// Turn the bounds into latlng.
|
|
782
|
+
new google.maps.LatLng(bounds.getSouthWest().lat(), bounds.getSouthWest().lng()));
|
|
783
|
+
blPix.x -= this.gridSize;
|
|
784
|
+
blPix.y += this.gridSize;
|
|
785
|
+
// Extend the bounds to contain the new bounds.
|
|
786
|
+
bounds.extend(
|
|
787
|
+
// Convert the pixel points back to LatLng nw
|
|
788
|
+
projection.fromDivPixelToLatLng(trPix));
|
|
789
|
+
bounds.extend(
|
|
790
|
+
// Convert the pixel points back to LatLng sw
|
|
791
|
+
projection.fromDivPixelToLatLng(blPix));
|
|
792
|
+
return bounds;
|
|
793
|
+
};
|
|
794
|
+
Clusterer.prototype.redraw = function () {
|
|
795
|
+
// Redraws all the clusters.
|
|
796
|
+
this.createClusters(0);
|
|
797
|
+
};
|
|
798
|
+
Clusterer.prototype.resetViewport = function (optHide) {
|
|
799
|
+
// Remove all the clusters
|
|
800
|
+
for (var i = 0; i < this.clusters.length; i++) {
|
|
801
|
+
this.clusters[i].remove();
|
|
802
|
+
}
|
|
803
|
+
this.clusters = [];
|
|
804
|
+
// Reset the markers to not be added and to be removed from the map.
|
|
805
|
+
for (var i = 0; i < this.markers.length; i++) {
|
|
806
|
+
var marker = this.markers[i];
|
|
807
|
+
marker.isAdded = false;
|
|
808
|
+
if (optHide) {
|
|
809
|
+
marker.setMap(null);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
Clusterer.prototype.distanceBetweenPoints = function (p1, p2) {
|
|
814
|
+
var R = 6371; // Radius of the Earth in km
|
|
815
|
+
var dLat = ((p2.lat() - p1.lat()) * Math.PI) / 180;
|
|
816
|
+
var dLon = ((p2.lng() - p1.lng()) * Math.PI) / 180;
|
|
817
|
+
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
|
|
818
|
+
Math.cos((p1.lat() * Math.PI) / 180) *
|
|
819
|
+
Math.cos((p2.lat() * Math.PI) / 180) *
|
|
820
|
+
Math.sin(dLon / 2) *
|
|
821
|
+
Math.sin(dLon / 2);
|
|
822
|
+
return R * (2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)));
|
|
823
|
+
};
|
|
824
|
+
Clusterer.prototype.isMarkerInBounds = function (marker, bounds) {
|
|
825
|
+
var position = marker.getPosition();
|
|
826
|
+
if (position) {
|
|
827
|
+
return bounds.contains(position);
|
|
828
|
+
}
|
|
829
|
+
return false;
|
|
830
|
+
};
|
|
831
|
+
Clusterer.prototype.addToClosestCluster = function (marker) {
|
|
832
|
+
var cluster;
|
|
833
|
+
var distance = 40000; // Some large number
|
|
834
|
+
var clusterToAddTo = null;
|
|
835
|
+
for (var i = 0; i < this.clusters.length; i++) {
|
|
836
|
+
cluster = this.clusters[i];
|
|
837
|
+
var center = cluster.getCenter();
|
|
838
|
+
var position = marker.getPosition();
|
|
839
|
+
if (center && position) {
|
|
840
|
+
var d = this.distanceBetweenPoints(center, position);
|
|
841
|
+
if (d < distance) {
|
|
842
|
+
distance = d;
|
|
843
|
+
clusterToAddTo = cluster;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
if (clusterToAddTo && clusterToAddTo.isMarkerInClusterBounds(marker)) {
|
|
848
|
+
clusterToAddTo.addMarker(marker);
|
|
849
|
+
}
|
|
850
|
+
else {
|
|
851
|
+
cluster = new Cluster(this);
|
|
852
|
+
cluster.addMarker(marker);
|
|
853
|
+
this.clusters.push(cluster);
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
Clusterer.prototype.createClusters = function (iFirst) {
|
|
857
|
+
var _this = this;
|
|
858
|
+
if (!this.ready) {
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
// Cancel previous batch processing if we're working on the first batch:
|
|
862
|
+
if (iFirst === 0) {
|
|
863
|
+
/**
|
|
864
|
+
* This event is fired when the <code>Clusterer</code> begins
|
|
865
|
+
* clustering markers.
|
|
866
|
+
* @name Clusterer#clusteringbegin
|
|
867
|
+
* @param {Clusterer} mc The Clusterer whose markers are being clustered.
|
|
868
|
+
* @event
|
|
869
|
+
*/
|
|
870
|
+
google.maps.event.trigger(this, 'clusteringbegin', this);
|
|
871
|
+
if (this.timerRefStatic !== null) {
|
|
872
|
+
window.clearTimeout(this.timerRefStatic);
|
|
873
|
+
// @ts-ignore
|
|
874
|
+
delete this.timerRefStatic;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
// Get our current map view bounds.
|
|
878
|
+
// Create a new bounds object so we don't affect the map.
|
|
879
|
+
//
|
|
880
|
+
// See Comments 9 & 11 on Issue 3651 relating to this workaround for a Google Maps bug:
|
|
881
|
+
var mapBounds =
|
|
882
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
883
|
+
// @ts-ignore
|
|
884
|
+
this.getMap().getZoom() > 3
|
|
885
|
+
? new google.maps.LatLngBounds(
|
|
886
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
887
|
+
// @ts-ignore
|
|
888
|
+
this.getMap()
|
|
889
|
+
.getBounds()
|
|
890
|
+
.getSouthWest(),
|
|
891
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
892
|
+
// @ts-ignore
|
|
893
|
+
this.getMap()
|
|
894
|
+
.getBounds()
|
|
895
|
+
.getNorthEast())
|
|
896
|
+
: new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472, -178.48388434375), new google.maps.LatLng(-85.08136444384544, 178.00048865625));
|
|
897
|
+
var bounds = this.getExtendedBounds(mapBounds);
|
|
898
|
+
var iLast = Math.min(iFirst + this.batchSize, this.markers.length);
|
|
899
|
+
for (var i = iFirst; i < iLast; i++) {
|
|
900
|
+
var marker = this.markers[i];
|
|
901
|
+
if (!marker.isAdded && this.isMarkerInBounds(marker, bounds)) {
|
|
902
|
+
if (!this.ignoreHidden || (this.ignoreHidden && marker.getVisible())) {
|
|
903
|
+
this.addToClosestCluster(marker);
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
if (iLast < this.markers.length) {
|
|
908
|
+
this.timerRefStatic = window.setTimeout(
|
|
909
|
+
// eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
|
|
910
|
+
function () {
|
|
911
|
+
_this.createClusters(iLast);
|
|
912
|
+
}, 0);
|
|
913
|
+
}
|
|
914
|
+
else {
|
|
915
|
+
this.timerRefStatic = null;
|
|
916
|
+
/**
|
|
917
|
+
* This event is fired when the <code>Clusterer</code> stops
|
|
918
|
+
* clustering markers.
|
|
919
|
+
* @name Clusterer#clusteringend
|
|
920
|
+
* @param {Clusterer} mc The Clusterer whose markers are being clustered.
|
|
921
|
+
* @event
|
|
922
|
+
*/
|
|
923
|
+
google.maps.event.trigger(this, 'clusteringend', this);
|
|
924
|
+
for (var i = 0; i < this.clusters.length; i++) {
|
|
925
|
+
this.clusters[i].updateIcon();
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
Clusterer.prototype.extend = function (obj1, obj2) {
|
|
930
|
+
return function applyExtend(object) {
|
|
931
|
+
// eslint-disable-next-line guard-for-in
|
|
932
|
+
for (var property in object.prototype) {
|
|
933
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
934
|
+
// @ts-ignore
|
|
935
|
+
this.prototype[property] = object.prototype[property];
|
|
936
|
+
}
|
|
937
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
938
|
+
// @ts-ignore
|
|
939
|
+
return this;
|
|
940
|
+
}.apply(obj1, [obj2]);
|
|
941
|
+
};
|
|
942
|
+
return Clusterer;
|
|
943
|
+
}());
|
|
940
944
|
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
945
|
+
exports.Cluster = Cluster;
|
|
946
|
+
exports.ClusterIcon = ClusterIcon;
|
|
947
|
+
exports.Clusterer = Clusterer;
|
|
944
948
|
|
|
945
|
-
|
|
949
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
946
950
|
|
|
947
|
-
}))
|
|
951
|
+
}));
|
|
948
952
|
//# sourceMappingURL=umd.js.map
|