@react-google-maps/marker-clusterer 2.10.1 → 2.11.2
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 +166 -150
- 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 +166 -150
- 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 +7 -5
- package/dist/umd.js +166 -150
- 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 +2 -2
- package/src/Cluster.tsx +5 -9
- package/src/ClusterIcon.tsx +72 -46
- package/src/Clusterer.tsx +92 -82
package/dist/umd.js
CHANGED
|
@@ -4,6 +4,37 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.markerClusterer = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
+
/******************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
9
|
+
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
+
***************************************************************************** */
|
|
21
|
+
/* global Reflect, Promise */
|
|
22
|
+
|
|
23
|
+
var extendStatics = function(d, b) {
|
|
24
|
+
extendStatics = Object.setPrototypeOf ||
|
|
25
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
26
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
27
|
+
return extendStatics(d, b);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function __extends(d, b) {
|
|
31
|
+
if (typeof b !== "function" && b !== null)
|
|
32
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
33
|
+
extendStatics(d, b);
|
|
34
|
+
function __() { this.constructor = d; }
|
|
35
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
36
|
+
}
|
|
37
|
+
|
|
7
38
|
var ClusterIcon = /** @class */ (function () {
|
|
8
39
|
function ClusterIcon(cluster, styles) {
|
|
9
40
|
cluster.getClusterer().extend(ClusterIcon, google.maps.OverlayView);
|
|
@@ -31,8 +62,6 @@
|
|
|
31
62
|
this.cMouseDownInCluster = null;
|
|
32
63
|
this.cDraggingMapByCluster = null;
|
|
33
64
|
this.timeOut = null;
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
35
|
-
// @ts-ignore
|
|
36
65
|
this.setMap(cluster.getMap()); // Note: this causes onAdd to be called
|
|
37
66
|
}
|
|
38
67
|
ClusterIcon.prototype.onBoundsChanged = function () {
|
|
@@ -60,22 +89,23 @@
|
|
|
60
89
|
// Zoom into the cluster.
|
|
61
90
|
var maxZoom_1 = markerClusterer_1.getMaxZoom();
|
|
62
91
|
var bounds_1 = this.cluster.getBounds();
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
92
|
+
var map = markerClusterer_1.getMap();
|
|
93
|
+
if (map !== null && 'fitBounds' in map) {
|
|
94
|
+
map.fitBounds(bounds_1);
|
|
95
|
+
}
|
|
66
96
|
// There is a fix for Issue 170 here:
|
|
67
97
|
this.timeOut = window.setTimeout(function () {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
98
|
+
var map = markerClusterer_1.getMap();
|
|
99
|
+
if (map !== null) {
|
|
100
|
+
if ('fitBounds' in map) {
|
|
101
|
+
map.fitBounds(bounds_1);
|
|
102
|
+
}
|
|
103
|
+
var zoom = map.getZoom() || 0;
|
|
104
|
+
// Don't zoom beyond the max zoom level
|
|
105
|
+
if (maxZoom_1 !== null &&
|
|
106
|
+
zoom > maxZoom_1) {
|
|
107
|
+
map.setZoom(maxZoom_1 + 1);
|
|
108
|
+
}
|
|
79
109
|
}
|
|
80
110
|
}, 100);
|
|
81
111
|
}
|
|
@@ -105,23 +135,22 @@
|
|
|
105
135
|
google.maps.event.trigger(this.cluster.getClusterer(), 'mouseout', this.cluster);
|
|
106
136
|
};
|
|
107
137
|
ClusterIcon.prototype.onAdd = function () {
|
|
138
|
+
var _a;
|
|
108
139
|
this.div = document.createElement('div');
|
|
109
140
|
this.div.className = this.className;
|
|
110
141
|
if (this.visible) {
|
|
111
142
|
this.show();
|
|
112
143
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
this.div.addEventListener('mouseover', this.onMouseOver);
|
|
124
|
-
this.div.addEventListener('mouseout', this.onMouseOut);
|
|
144
|
+
(_a = this.getPanes()) === null || _a === void 0 ? void 0 : _a.overlayMouseTarget.appendChild(this.div);
|
|
145
|
+
var map = this.getMap();
|
|
146
|
+
if (map !== null) {
|
|
147
|
+
// Fix for Issue 157
|
|
148
|
+
this.boundsChangedListener = google.maps.event.addListener(map, 'bounds_changed', this.onBoundsChanged);
|
|
149
|
+
this.div.addEventListener('mousedown', this.onMouseDown);
|
|
150
|
+
this.div.addEventListener('click', this.onClick);
|
|
151
|
+
this.div.addEventListener('mouseover', this.onMouseOver);
|
|
152
|
+
this.div.addEventListener('mouseout', this.onMouseOut);
|
|
153
|
+
}
|
|
125
154
|
};
|
|
126
155
|
ClusterIcon.prototype.onRemove = function () {
|
|
127
156
|
if (this.div && this.div.parentNode) {
|
|
@@ -143,9 +172,9 @@
|
|
|
143
172
|
};
|
|
144
173
|
ClusterIcon.prototype.draw = function () {
|
|
145
174
|
if (this.visible && this.div !== null && this.center) {
|
|
146
|
-
var
|
|
147
|
-
this.div.style.top = "".concat(y, "px");
|
|
148
|
-
this.div.style.left = "".concat(x, "px");
|
|
175
|
+
var pos = this.getPosFromLatLng(this.center);
|
|
176
|
+
this.div.style.top = pos !== null ? "".concat(pos.y, "px") : '0';
|
|
177
|
+
this.div.style.left = pos !== null ? "".concat(pos.x, "px") : '0';
|
|
149
178
|
}
|
|
150
179
|
};
|
|
151
180
|
ClusterIcon.prototype.hide = function () {
|
|
@@ -173,8 +202,8 @@
|
|
|
173
202
|
}
|
|
174
203
|
this.div.style.cursor = 'pointer';
|
|
175
204
|
this.div.style.position = 'absolute';
|
|
176
|
-
this.div.style.top = "".concat(pos.y, "px");
|
|
177
|
-
this.div.style.left = "".concat(pos.x, "px");
|
|
205
|
+
this.div.style.top = pos !== null ? "".concat(pos.y, "px") : '0';
|
|
206
|
+
this.div.style.left = pos !== null ? "".concat(pos.x, "px") : '0';
|
|
178
207
|
this.div.style.width = "".concat(this.width, "px");
|
|
179
208
|
this.div.style.height = "".concat(this.height, "px");
|
|
180
209
|
var img = document.createElement('img');
|
|
@@ -231,10 +260,11 @@
|
|
|
231
260
|
this.center = center;
|
|
232
261
|
};
|
|
233
262
|
ClusterIcon.prototype.getPosFromLatLng = function (latlng) {
|
|
234
|
-
// @ts-ignore
|
|
235
263
|
var pos = this.getProjection().fromLatLngToDivPixel(latlng);
|
|
236
|
-
pos
|
|
237
|
-
|
|
264
|
+
if (pos !== null) {
|
|
265
|
+
pos.x -= this.anchorIcon[1];
|
|
266
|
+
pos.y -= this.anchorIcon[0];
|
|
267
|
+
}
|
|
238
268
|
return pos;
|
|
239
269
|
};
|
|
240
270
|
return ClusterIcon;
|
|
@@ -243,8 +273,6 @@
|
|
|
243
273
|
var Cluster = /** @class */ (function () {
|
|
244
274
|
function Cluster(markerClusterer) {
|
|
245
275
|
this.markerClusterer = markerClusterer;
|
|
246
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
247
|
-
// @ts-ignore
|
|
248
276
|
this.map = this.markerClusterer.getMap();
|
|
249
277
|
this.gridSize = this.markerClusterer.getGridSize();
|
|
250
278
|
this.minClusterSize = this.markerClusterer.getMinimumClusterSize();
|
|
@@ -281,8 +309,6 @@
|
|
|
281
309
|
return bounds;
|
|
282
310
|
};
|
|
283
311
|
Cluster.prototype.remove = function () {
|
|
284
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
285
|
-
// @ts-ignore
|
|
286
312
|
this.clusterIcon.setMap(null);
|
|
287
313
|
this.markers = [];
|
|
288
314
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -290,6 +316,7 @@
|
|
|
290
316
|
delete this.markers;
|
|
291
317
|
};
|
|
292
318
|
Cluster.prototype.addMarker = function (marker) {
|
|
319
|
+
var _a;
|
|
293
320
|
if (this.isMarkerAlreadyAdded(marker)) {
|
|
294
321
|
return false;
|
|
295
322
|
}
|
|
@@ -314,7 +341,7 @@
|
|
|
314
341
|
this.markers.push(marker);
|
|
315
342
|
var mCount = this.markers.length;
|
|
316
343
|
var maxZoom = this.markerClusterer.getMaxZoom();
|
|
317
|
-
var zoom = this.map.getZoom();
|
|
344
|
+
var zoom = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom();
|
|
318
345
|
if (maxZoom !== null && typeof zoom !== 'undefined' && zoom > maxZoom) {
|
|
319
346
|
// Zoomed in past max zoom, so show the marker.
|
|
320
347
|
if (marker.getMap() !== this.map) {
|
|
@@ -351,9 +378,10 @@
|
|
|
351
378
|
this.bounds = this.markerClusterer.getExtendedBounds(new google.maps.LatLngBounds(this.center, this.center));
|
|
352
379
|
};
|
|
353
380
|
Cluster.prototype.updateIcon = function () {
|
|
381
|
+
var _a;
|
|
354
382
|
var mCount = this.markers.length;
|
|
355
383
|
var maxZoom = this.markerClusterer.getMaxZoom();
|
|
356
|
-
var zoom = this.map.getZoom();
|
|
384
|
+
var zoom = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom();
|
|
357
385
|
if (maxZoom !== null && typeof zoom !== 'undefined' && zoom > maxZoom) {
|
|
358
386
|
this.clusterIcon.hide();
|
|
359
387
|
return;
|
|
@@ -383,7 +411,6 @@
|
|
|
383
411
|
return Cluster;
|
|
384
412
|
}());
|
|
385
413
|
|
|
386
|
-
/* global google */
|
|
387
414
|
/**
|
|
388
415
|
* Supports up to 9007199254740991 (Number.MAX_SAFE_INTEGER) markers
|
|
389
416
|
* which is not a problem as max array length is 4294967296 (2**32)
|
|
@@ -404,91 +431,84 @@
|
|
|
404
431
|
var IMAGE_EXTENSION = 'png';
|
|
405
432
|
var IMAGE_SIZES = [53, 56, 66, 78, 90];
|
|
406
433
|
var CLUSTERER_CLASS = 'cluster';
|
|
407
|
-
var Clusterer = /** @class */ (function () {
|
|
434
|
+
var Clusterer = /** @class */ (function (_super) {
|
|
435
|
+
__extends(Clusterer, _super);
|
|
408
436
|
function Clusterer(map, optMarkers, optOptions) {
|
|
409
437
|
if (optMarkers === void 0) { optMarkers = []; }
|
|
410
438
|
if (optOptions === void 0) { optOptions = {}; }
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
439
|
+
var _this = _super.call(this) || this;
|
|
440
|
+
_this.extend(Clusterer, google.maps.OverlayView);
|
|
441
|
+
_this.markers = [];
|
|
442
|
+
_this.clusters = [];
|
|
443
|
+
_this.listeners = [];
|
|
444
|
+
_this.activeMap = null;
|
|
445
|
+
_this.ready = false;
|
|
446
|
+
_this.gridSize = optOptions.gridSize || 60;
|
|
447
|
+
_this.minClusterSize = optOptions.minimumClusterSize || 2;
|
|
448
|
+
_this.maxZoom = optOptions.maxZoom || null;
|
|
449
|
+
_this.styles = optOptions.styles || [];
|
|
450
|
+
_this.title = optOptions.title || '';
|
|
451
|
+
_this.zoomOnClick = true;
|
|
423
452
|
if (optOptions.zoomOnClick !== undefined) {
|
|
424
|
-
|
|
453
|
+
_this.zoomOnClick = optOptions.zoomOnClick;
|
|
425
454
|
}
|
|
426
|
-
|
|
455
|
+
_this.averageCenter = false;
|
|
427
456
|
if (optOptions.averageCenter !== undefined) {
|
|
428
|
-
|
|
457
|
+
_this.averageCenter = optOptions.averageCenter;
|
|
429
458
|
}
|
|
430
|
-
|
|
459
|
+
_this.ignoreHidden = false;
|
|
431
460
|
if (optOptions.ignoreHidden !== undefined) {
|
|
432
|
-
|
|
461
|
+
_this.ignoreHidden = optOptions.ignoreHidden;
|
|
433
462
|
}
|
|
434
|
-
|
|
463
|
+
_this.enableRetinaIcons = false;
|
|
435
464
|
if (optOptions.enableRetinaIcons !== undefined) {
|
|
436
|
-
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
465
|
+
_this.enableRetinaIcons = optOptions.enableRetinaIcons;
|
|
466
|
+
}
|
|
467
|
+
_this.imagePath = optOptions.imagePath || IMAGE_PATH;
|
|
468
|
+
_this.imageExtension = optOptions.imageExtension || IMAGE_EXTENSION;
|
|
469
|
+
_this.imageSizes = optOptions.imageSizes || IMAGE_SIZES;
|
|
470
|
+
_this.calculator = optOptions.calculator || CALCULATOR;
|
|
471
|
+
_this.batchSize = optOptions.batchSize || BATCH_SIZE;
|
|
472
|
+
_this.batchSizeIE = optOptions.batchSizeIE || BATCH_SIZE_IE;
|
|
473
|
+
_this.clusterClass = optOptions.clusterClass || CLUSTERER_CLASS;
|
|
445
474
|
if (navigator.userAgent.toLowerCase().indexOf('msie') !== -1) {
|
|
446
475
|
// Try to avoid IE timeout when processing a huge number of markers:
|
|
447
|
-
|
|
476
|
+
_this.batchSize = _this.batchSizeIE;
|
|
448
477
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
//
|
|
453
|
-
|
|
454
|
-
this.setMap(map); // Note: this causes onAdd to be called
|
|
478
|
+
_this.timerRefStatic = null;
|
|
479
|
+
_this.setupStyles();
|
|
480
|
+
_this.addMarkers(optMarkers, true);
|
|
481
|
+
_this.setMap(map); // Note: this causes onAdd to be called
|
|
482
|
+
return _this;
|
|
455
483
|
}
|
|
484
|
+
Clusterer.prototype.onZoomChanged = function () {
|
|
485
|
+
var _a, _b;
|
|
486
|
+
this.resetViewport(false);
|
|
487
|
+
// Workaround for this Google bug: when map is at level 0 and "-" of
|
|
488
|
+
// zoom slider is clicked, a "zoom_changed" event is fired even though
|
|
489
|
+
// the map doesn't zoom out any further. In this situation, no "idle"
|
|
490
|
+
// event is triggered so the cluster markers that have been removed
|
|
491
|
+
// do not get redrawn. Same goes for a zoom in at maxZoom.
|
|
492
|
+
if (((_a = this.getMap()) === null || _a === void 0 ? void 0 : _a.getZoom()) === (this.get('minZoom') || 0) ||
|
|
493
|
+
((_b = this.getMap()) === null || _b === void 0 ? void 0 : _b.getZoom()) === this.get('maxZoom')) {
|
|
494
|
+
google.maps.event.trigger(this, 'idle');
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
Clusterer.prototype.onIdle = function () {
|
|
498
|
+
this.redraw();
|
|
499
|
+
};
|
|
456
500
|
Clusterer.prototype.onAdd = function () {
|
|
457
|
-
var
|
|
458
|
-
|
|
459
|
-
// @ts-ignore
|
|
460
|
-
this.activeMap = this.getMap();
|
|
501
|
+
var map = this.getMap();
|
|
502
|
+
this.activeMap = map;
|
|
461
503
|
this.ready = true;
|
|
462
504
|
this.repaint();
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
// Workaround for this Google bug: when map is at level 0 and "-" of
|
|
471
|
-
// zoom slider is clicked, a "zoom_changed" event is fired even though
|
|
472
|
-
// the map doesn't zoom out any further. In this situation, no "idle"
|
|
473
|
-
// event is triggered so the cluster markers that have been removed
|
|
474
|
-
// do not get redrawn. Same goes for a zoom in at maxZoom.
|
|
475
|
-
if (
|
|
476
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
477
|
-
// @ts-ignore
|
|
478
|
-
_this.getMap().getZoom() === (_this.get('minZoom') || 0) ||
|
|
479
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
480
|
-
// @ts-ignore
|
|
481
|
-
_this.getMap().getZoom() === _this.get('maxZoom')) {
|
|
482
|
-
google.maps.event.trigger(_this, 'idle');
|
|
483
|
-
}
|
|
484
|
-
}),
|
|
485
|
-
google.maps.event.addListener(
|
|
486
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
487
|
-
// @ts-ignore
|
|
488
|
-
this.getMap(), 'idle', function () {
|
|
489
|
-
_this.redraw();
|
|
490
|
-
}),
|
|
491
|
-
];
|
|
505
|
+
if (map !== null) {
|
|
506
|
+
// Add the map event listeners
|
|
507
|
+
this.listeners = [
|
|
508
|
+
google.maps.event.addListener(map, 'zoom_changed', this.onZoomChanged),
|
|
509
|
+
google.maps.event.addListener(map, 'idle', this.onIdle),
|
|
510
|
+
];
|
|
511
|
+
}
|
|
492
512
|
};
|
|
493
513
|
Clusterer.prototype.onRemove = function () {
|
|
494
514
|
// Put all the managed markers back on the map:
|
|
@@ -533,9 +553,10 @@
|
|
|
533
553
|
bounds.extend(position);
|
|
534
554
|
}
|
|
535
555
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
556
|
+
var map = this.getMap();
|
|
557
|
+
if (map !== null && 'fitBounds' in map) {
|
|
558
|
+
map.fitBounds(bounds);
|
|
559
|
+
}
|
|
539
560
|
};
|
|
540
561
|
Clusterer.prototype.getGridSize = function () {
|
|
541
562
|
return this.gridSize;
|
|
@@ -725,27 +746,37 @@
|
|
|
725
746
|
}, 0);
|
|
726
747
|
};
|
|
727
748
|
Clusterer.prototype.getExtendedBounds = function (bounds) {
|
|
728
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
729
|
-
// @ts-ignore
|
|
730
749
|
var projection = this.getProjection();
|
|
731
750
|
// Convert the points to pixels and the extend out by the grid size.
|
|
732
751
|
var trPix = projection.fromLatLngToDivPixel(
|
|
733
752
|
// Turn the bounds into latlng.
|
|
734
753
|
new google.maps.LatLng(bounds.getNorthEast().lat(), bounds.getNorthEast().lng()));
|
|
735
|
-
trPix
|
|
736
|
-
|
|
754
|
+
if (trPix !== null) {
|
|
755
|
+
trPix.x += this.gridSize;
|
|
756
|
+
trPix.y -= this.gridSize;
|
|
757
|
+
}
|
|
737
758
|
var blPix = projection.fromLatLngToDivPixel(
|
|
738
759
|
// Turn the bounds into latlng.
|
|
739
760
|
new google.maps.LatLng(bounds.getSouthWest().lat(), bounds.getSouthWest().lng()));
|
|
740
|
-
blPix
|
|
741
|
-
|
|
761
|
+
if (blPix !== null) {
|
|
762
|
+
blPix.x -= this.gridSize;
|
|
763
|
+
blPix.y += this.gridSize;
|
|
764
|
+
}
|
|
742
765
|
// Extend the bounds to contain the new bounds.
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
766
|
+
if (trPix !== null) {
|
|
767
|
+
// Convert the pixel points back to LatLng nw
|
|
768
|
+
var point1 = projection.fromDivPixelToLatLng(trPix);
|
|
769
|
+
if (point1 !== null) {
|
|
770
|
+
bounds.extend(point1);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
if (blPix !== null) {
|
|
774
|
+
// Convert the pixel points back to LatLng sw
|
|
775
|
+
var point2 = projection.fromDivPixelToLatLng(blPix);
|
|
776
|
+
if (point2 !== null) {
|
|
777
|
+
bounds.extend(point2);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
749
780
|
return bounds;
|
|
750
781
|
};
|
|
751
782
|
Clusterer.prototype.redraw = function () {
|
|
@@ -832,31 +863,21 @@
|
|
|
832
863
|
delete this.timerRefStatic;
|
|
833
864
|
}
|
|
834
865
|
}
|
|
866
|
+
var map = this.getMap();
|
|
867
|
+
var bounds = map !== null && 'getBounds' in map ? map.getBounds() : null;
|
|
868
|
+
var zoom = (map === null || map === void 0 ? void 0 : map.getZoom()) || 0;
|
|
835
869
|
// Get our current map view bounds.
|
|
836
870
|
// Create a new bounds object so we don't affect the map.
|
|
837
871
|
//
|
|
838
872
|
// See Comments 9 & 11 on Issue 3651 relating to this workaround for a Google Maps bug:
|
|
839
|
-
var mapBounds =
|
|
840
|
-
|
|
841
|
-
// @ts-ignore
|
|
842
|
-
this.getMap().getZoom() > 3
|
|
843
|
-
? new google.maps.LatLngBounds(
|
|
844
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
845
|
-
// @ts-ignore
|
|
846
|
-
this.getMap()
|
|
847
|
-
.getBounds()
|
|
848
|
-
.getSouthWest(),
|
|
849
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
850
|
-
// @ts-ignore
|
|
851
|
-
this.getMap()
|
|
852
|
-
.getBounds()
|
|
853
|
-
.getNorthEast())
|
|
873
|
+
var mapBounds = zoom > 3
|
|
874
|
+
? new google.maps.LatLngBounds(bounds === null || bounds === void 0 ? void 0 : bounds.getSouthWest(), bounds === null || bounds === void 0 ? void 0 : bounds.getNorthEast())
|
|
854
875
|
: new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472, -178.48388434375), new google.maps.LatLng(-85.08136444384544, 178.00048865625));
|
|
855
|
-
var
|
|
876
|
+
var extendedMapBounds = this.getExtendedBounds(mapBounds);
|
|
856
877
|
var iLast = Math.min(iFirst + this.batchSize, this.markers.length);
|
|
857
878
|
for (var i = iFirst; i < iLast; i++) {
|
|
858
879
|
var marker = this.markers[i];
|
|
859
|
-
if (!marker.isAdded && this.isMarkerInBounds(marker,
|
|
880
|
+
if (!marker.isAdded && this.isMarkerInBounds(marker, extendedMapBounds) && (!this.ignoreHidden || (this.ignoreHidden && marker.getVisible()))) {
|
|
860
881
|
this.addToClosestCluster(marker);
|
|
861
882
|
}
|
|
862
883
|
}
|
|
@@ -882,19 +903,14 @@
|
|
|
882
903
|
};
|
|
883
904
|
Clusterer.prototype.extend = function (obj1, obj2) {
|
|
884
905
|
return function applyExtend(object) {
|
|
885
|
-
// eslint-disable-next-line guard-for-in
|
|
886
906
|
for (var property in object.prototype) {
|
|
887
|
-
|
|
888
|
-
// @ts-ignore
|
|
889
|
-
this.prototype[property] = object.prototype[property];
|
|
907
|
+
this.prototype.set(property, object.prototype.get(property));
|
|
890
908
|
}
|
|
891
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
892
|
-
// @ts-ignore
|
|
893
909
|
return this;
|
|
894
910
|
}.apply(obj1, [obj2]);
|
|
895
911
|
};
|
|
896
912
|
return Clusterer;
|
|
897
|
-
}());
|
|
913
|
+
}(google.maps.OverlayView));
|
|
898
914
|
|
|
899
915
|
exports.Cluster = Cluster;
|
|
900
916
|
exports.ClusterIcon = ClusterIcon;
|