@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/esm.js
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
/* global Reflect, Promise */
|
|
16
|
+
|
|
17
|
+
var extendStatics = function(d, b) {
|
|
18
|
+
extendStatics = Object.setPrototypeOf ||
|
|
19
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
20
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
21
|
+
return extendStatics(d, b);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function __extends(d, b) {
|
|
25
|
+
if (typeof b !== "function" && b !== null)
|
|
26
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
27
|
+
extendStatics(d, b);
|
|
28
|
+
function __() { this.constructor = d; }
|
|
29
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
|
+
}
|
|
31
|
+
|
|
1
32
|
var ClusterIcon = /** @class */ (function () {
|
|
2
33
|
function ClusterIcon(cluster, styles) {
|
|
3
34
|
cluster.getClusterer().extend(ClusterIcon, google.maps.OverlayView);
|
|
@@ -25,8 +56,6 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
25
56
|
this.cMouseDownInCluster = null;
|
|
26
57
|
this.cDraggingMapByCluster = null;
|
|
27
58
|
this.timeOut = null;
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
29
|
-
// @ts-ignore
|
|
30
59
|
this.setMap(cluster.getMap()); // Note: this causes onAdd to be called
|
|
31
60
|
}
|
|
32
61
|
ClusterIcon.prototype.onBoundsChanged = function () {
|
|
@@ -54,22 +83,23 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
54
83
|
// Zoom into the cluster.
|
|
55
84
|
var maxZoom_1 = markerClusterer_1.getMaxZoom();
|
|
56
85
|
var bounds_1 = this.cluster.getBounds();
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
86
|
+
var map = markerClusterer_1.getMap();
|
|
87
|
+
if (map !== null && 'fitBounds' in map) {
|
|
88
|
+
map.fitBounds(bounds_1);
|
|
89
|
+
}
|
|
60
90
|
// There is a fix for Issue 170 here:
|
|
61
91
|
this.timeOut = window.setTimeout(function () {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
92
|
+
var map = markerClusterer_1.getMap();
|
|
93
|
+
if (map !== null) {
|
|
94
|
+
if ('fitBounds' in map) {
|
|
95
|
+
map.fitBounds(bounds_1);
|
|
96
|
+
}
|
|
97
|
+
var zoom = map.getZoom() || 0;
|
|
98
|
+
// Don't zoom beyond the max zoom level
|
|
99
|
+
if (maxZoom_1 !== null &&
|
|
100
|
+
zoom > maxZoom_1) {
|
|
101
|
+
map.setZoom(maxZoom_1 + 1);
|
|
102
|
+
}
|
|
73
103
|
}
|
|
74
104
|
}, 100);
|
|
75
105
|
}
|
|
@@ -99,23 +129,22 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
99
129
|
google.maps.event.trigger(this.cluster.getClusterer(), 'mouseout', this.cluster);
|
|
100
130
|
};
|
|
101
131
|
ClusterIcon.prototype.onAdd = function () {
|
|
132
|
+
var _a;
|
|
102
133
|
this.div = document.createElement('div');
|
|
103
134
|
this.div.className = this.className;
|
|
104
135
|
if (this.visible) {
|
|
105
136
|
this.show();
|
|
106
137
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
this.div.addEventListener('mouseover', this.onMouseOver);
|
|
118
|
-
this.div.addEventListener('mouseout', this.onMouseOut);
|
|
138
|
+
(_a = this.getPanes()) === null || _a === void 0 ? void 0 : _a.overlayMouseTarget.appendChild(this.div);
|
|
139
|
+
var map = this.getMap();
|
|
140
|
+
if (map !== null) {
|
|
141
|
+
// Fix for Issue 157
|
|
142
|
+
this.boundsChangedListener = google.maps.event.addListener(map, 'bounds_changed', this.onBoundsChanged);
|
|
143
|
+
this.div.addEventListener('mousedown', this.onMouseDown);
|
|
144
|
+
this.div.addEventListener('click', this.onClick);
|
|
145
|
+
this.div.addEventListener('mouseover', this.onMouseOver);
|
|
146
|
+
this.div.addEventListener('mouseout', this.onMouseOut);
|
|
147
|
+
}
|
|
119
148
|
};
|
|
120
149
|
ClusterIcon.prototype.onRemove = function () {
|
|
121
150
|
if (this.div && this.div.parentNode) {
|
|
@@ -137,9 +166,9 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
137
166
|
};
|
|
138
167
|
ClusterIcon.prototype.draw = function () {
|
|
139
168
|
if (this.visible && this.div !== null && this.center) {
|
|
140
|
-
var
|
|
141
|
-
this.div.style.top = "".concat(y, "px");
|
|
142
|
-
this.div.style.left = "".concat(x, "px");
|
|
169
|
+
var pos = this.getPosFromLatLng(this.center);
|
|
170
|
+
this.div.style.top = pos !== null ? "".concat(pos.y, "px") : '0';
|
|
171
|
+
this.div.style.left = pos !== null ? "".concat(pos.x, "px") : '0';
|
|
143
172
|
}
|
|
144
173
|
};
|
|
145
174
|
ClusterIcon.prototype.hide = function () {
|
|
@@ -167,8 +196,8 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
167
196
|
}
|
|
168
197
|
this.div.style.cursor = 'pointer';
|
|
169
198
|
this.div.style.position = 'absolute';
|
|
170
|
-
this.div.style.top = "".concat(pos.y, "px");
|
|
171
|
-
this.div.style.left = "".concat(pos.x, "px");
|
|
199
|
+
this.div.style.top = pos !== null ? "".concat(pos.y, "px") : '0';
|
|
200
|
+
this.div.style.left = pos !== null ? "".concat(pos.x, "px") : '0';
|
|
172
201
|
this.div.style.width = "".concat(this.width, "px");
|
|
173
202
|
this.div.style.height = "".concat(this.height, "px");
|
|
174
203
|
var img = document.createElement('img');
|
|
@@ -225,10 +254,11 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
225
254
|
this.center = center;
|
|
226
255
|
};
|
|
227
256
|
ClusterIcon.prototype.getPosFromLatLng = function (latlng) {
|
|
228
|
-
// @ts-ignore
|
|
229
257
|
var pos = this.getProjection().fromLatLngToDivPixel(latlng);
|
|
230
|
-
pos
|
|
231
|
-
|
|
258
|
+
if (pos !== null) {
|
|
259
|
+
pos.x -= this.anchorIcon[1];
|
|
260
|
+
pos.y -= this.anchorIcon[0];
|
|
261
|
+
}
|
|
232
262
|
return pos;
|
|
233
263
|
};
|
|
234
264
|
return ClusterIcon;
|
|
@@ -237,8 +267,6 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
237
267
|
var Cluster = /** @class */ (function () {
|
|
238
268
|
function Cluster(markerClusterer) {
|
|
239
269
|
this.markerClusterer = markerClusterer;
|
|
240
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
241
|
-
// @ts-ignore
|
|
242
270
|
this.map = this.markerClusterer.getMap();
|
|
243
271
|
this.gridSize = this.markerClusterer.getGridSize();
|
|
244
272
|
this.minClusterSize = this.markerClusterer.getMinimumClusterSize();
|
|
@@ -275,8 +303,6 @@ var Cluster = /** @class */ (function () {
|
|
|
275
303
|
return bounds;
|
|
276
304
|
};
|
|
277
305
|
Cluster.prototype.remove = function () {
|
|
278
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
279
|
-
// @ts-ignore
|
|
280
306
|
this.clusterIcon.setMap(null);
|
|
281
307
|
this.markers = [];
|
|
282
308
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -284,6 +310,7 @@ var Cluster = /** @class */ (function () {
|
|
|
284
310
|
delete this.markers;
|
|
285
311
|
};
|
|
286
312
|
Cluster.prototype.addMarker = function (marker) {
|
|
313
|
+
var _a;
|
|
287
314
|
if (this.isMarkerAlreadyAdded(marker)) {
|
|
288
315
|
return false;
|
|
289
316
|
}
|
|
@@ -308,7 +335,7 @@ var Cluster = /** @class */ (function () {
|
|
|
308
335
|
this.markers.push(marker);
|
|
309
336
|
var mCount = this.markers.length;
|
|
310
337
|
var maxZoom = this.markerClusterer.getMaxZoom();
|
|
311
|
-
var zoom = this.map.getZoom();
|
|
338
|
+
var zoom = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom();
|
|
312
339
|
if (maxZoom !== null && typeof zoom !== 'undefined' && zoom > maxZoom) {
|
|
313
340
|
// Zoomed in past max zoom, so show the marker.
|
|
314
341
|
if (marker.getMap() !== this.map) {
|
|
@@ -345,9 +372,10 @@ var Cluster = /** @class */ (function () {
|
|
|
345
372
|
this.bounds = this.markerClusterer.getExtendedBounds(new google.maps.LatLngBounds(this.center, this.center));
|
|
346
373
|
};
|
|
347
374
|
Cluster.prototype.updateIcon = function () {
|
|
375
|
+
var _a;
|
|
348
376
|
var mCount = this.markers.length;
|
|
349
377
|
var maxZoom = this.markerClusterer.getMaxZoom();
|
|
350
|
-
var zoom = this.map.getZoom();
|
|
378
|
+
var zoom = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom();
|
|
351
379
|
if (maxZoom !== null && typeof zoom !== 'undefined' && zoom > maxZoom) {
|
|
352
380
|
this.clusterIcon.hide();
|
|
353
381
|
return;
|
|
@@ -377,7 +405,6 @@ var Cluster = /** @class */ (function () {
|
|
|
377
405
|
return Cluster;
|
|
378
406
|
}());
|
|
379
407
|
|
|
380
|
-
/* global google */
|
|
381
408
|
/**
|
|
382
409
|
* Supports up to 9007199254740991 (Number.MAX_SAFE_INTEGER) markers
|
|
383
410
|
* which is not a problem as max array length is 4294967296 (2**32)
|
|
@@ -398,91 +425,84 @@ var IMAGE_PATH = 'https://developers.google.com/maps/documentation/javascript/ex
|
|
|
398
425
|
var IMAGE_EXTENSION = 'png';
|
|
399
426
|
var IMAGE_SIZES = [53, 56, 66, 78, 90];
|
|
400
427
|
var CLUSTERER_CLASS = 'cluster';
|
|
401
|
-
var Clusterer = /** @class */ (function () {
|
|
428
|
+
var Clusterer = /** @class */ (function (_super) {
|
|
429
|
+
__extends(Clusterer, _super);
|
|
402
430
|
function Clusterer(map, optMarkers, optOptions) {
|
|
403
431
|
if (optMarkers === void 0) { optMarkers = []; }
|
|
404
432
|
if (optOptions === void 0) { optOptions = {}; }
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
433
|
+
var _this = _super.call(this) || this;
|
|
434
|
+
_this.extend(Clusterer, google.maps.OverlayView);
|
|
435
|
+
_this.markers = [];
|
|
436
|
+
_this.clusters = [];
|
|
437
|
+
_this.listeners = [];
|
|
438
|
+
_this.activeMap = null;
|
|
439
|
+
_this.ready = false;
|
|
440
|
+
_this.gridSize = optOptions.gridSize || 60;
|
|
441
|
+
_this.minClusterSize = optOptions.minimumClusterSize || 2;
|
|
442
|
+
_this.maxZoom = optOptions.maxZoom || null;
|
|
443
|
+
_this.styles = optOptions.styles || [];
|
|
444
|
+
_this.title = optOptions.title || '';
|
|
445
|
+
_this.zoomOnClick = true;
|
|
417
446
|
if (optOptions.zoomOnClick !== undefined) {
|
|
418
|
-
|
|
447
|
+
_this.zoomOnClick = optOptions.zoomOnClick;
|
|
419
448
|
}
|
|
420
|
-
|
|
449
|
+
_this.averageCenter = false;
|
|
421
450
|
if (optOptions.averageCenter !== undefined) {
|
|
422
|
-
|
|
451
|
+
_this.averageCenter = optOptions.averageCenter;
|
|
423
452
|
}
|
|
424
|
-
|
|
453
|
+
_this.ignoreHidden = false;
|
|
425
454
|
if (optOptions.ignoreHidden !== undefined) {
|
|
426
|
-
|
|
455
|
+
_this.ignoreHidden = optOptions.ignoreHidden;
|
|
427
456
|
}
|
|
428
|
-
|
|
457
|
+
_this.enableRetinaIcons = false;
|
|
429
458
|
if (optOptions.enableRetinaIcons !== undefined) {
|
|
430
|
-
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
459
|
+
_this.enableRetinaIcons = optOptions.enableRetinaIcons;
|
|
460
|
+
}
|
|
461
|
+
_this.imagePath = optOptions.imagePath || IMAGE_PATH;
|
|
462
|
+
_this.imageExtension = optOptions.imageExtension || IMAGE_EXTENSION;
|
|
463
|
+
_this.imageSizes = optOptions.imageSizes || IMAGE_SIZES;
|
|
464
|
+
_this.calculator = optOptions.calculator || CALCULATOR;
|
|
465
|
+
_this.batchSize = optOptions.batchSize || BATCH_SIZE;
|
|
466
|
+
_this.batchSizeIE = optOptions.batchSizeIE || BATCH_SIZE_IE;
|
|
467
|
+
_this.clusterClass = optOptions.clusterClass || CLUSTERER_CLASS;
|
|
439
468
|
if (navigator.userAgent.toLowerCase().indexOf('msie') !== -1) {
|
|
440
469
|
// Try to avoid IE timeout when processing a huge number of markers:
|
|
441
|
-
|
|
470
|
+
_this.batchSize = _this.batchSizeIE;
|
|
442
471
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
//
|
|
447
|
-
|
|
448
|
-
this.setMap(map); // Note: this causes onAdd to be called
|
|
472
|
+
_this.timerRefStatic = null;
|
|
473
|
+
_this.setupStyles();
|
|
474
|
+
_this.addMarkers(optMarkers, true);
|
|
475
|
+
_this.setMap(map); // Note: this causes onAdd to be called
|
|
476
|
+
return _this;
|
|
449
477
|
}
|
|
478
|
+
Clusterer.prototype.onZoomChanged = function () {
|
|
479
|
+
var _a, _b;
|
|
480
|
+
this.resetViewport(false);
|
|
481
|
+
// Workaround for this Google bug: when map is at level 0 and "-" of
|
|
482
|
+
// zoom slider is clicked, a "zoom_changed" event is fired even though
|
|
483
|
+
// the map doesn't zoom out any further. In this situation, no "idle"
|
|
484
|
+
// event is triggered so the cluster markers that have been removed
|
|
485
|
+
// do not get redrawn. Same goes for a zoom in at maxZoom.
|
|
486
|
+
if (((_a = this.getMap()) === null || _a === void 0 ? void 0 : _a.getZoom()) === (this.get('minZoom') || 0) ||
|
|
487
|
+
((_b = this.getMap()) === null || _b === void 0 ? void 0 : _b.getZoom()) === this.get('maxZoom')) {
|
|
488
|
+
google.maps.event.trigger(this, 'idle');
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
Clusterer.prototype.onIdle = function () {
|
|
492
|
+
this.redraw();
|
|
493
|
+
};
|
|
450
494
|
Clusterer.prototype.onAdd = function () {
|
|
451
|
-
var
|
|
452
|
-
|
|
453
|
-
// @ts-ignore
|
|
454
|
-
this.activeMap = this.getMap();
|
|
495
|
+
var map = this.getMap();
|
|
496
|
+
this.activeMap = map;
|
|
455
497
|
this.ready = true;
|
|
456
498
|
this.repaint();
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
// Workaround for this Google bug: when map is at level 0 and "-" of
|
|
465
|
-
// zoom slider is clicked, a "zoom_changed" event is fired even though
|
|
466
|
-
// the map doesn't zoom out any further. In this situation, no "idle"
|
|
467
|
-
// event is triggered so the cluster markers that have been removed
|
|
468
|
-
// do not get redrawn. Same goes for a zoom in at maxZoom.
|
|
469
|
-
if (
|
|
470
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
471
|
-
// @ts-ignore
|
|
472
|
-
_this.getMap().getZoom() === (_this.get('minZoom') || 0) ||
|
|
473
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
474
|
-
// @ts-ignore
|
|
475
|
-
_this.getMap().getZoom() === _this.get('maxZoom')) {
|
|
476
|
-
google.maps.event.trigger(_this, 'idle');
|
|
477
|
-
}
|
|
478
|
-
}),
|
|
479
|
-
google.maps.event.addListener(
|
|
480
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
481
|
-
// @ts-ignore
|
|
482
|
-
this.getMap(), 'idle', function () {
|
|
483
|
-
_this.redraw();
|
|
484
|
-
}),
|
|
485
|
-
];
|
|
499
|
+
if (map !== null) {
|
|
500
|
+
// Add the map event listeners
|
|
501
|
+
this.listeners = [
|
|
502
|
+
google.maps.event.addListener(map, 'zoom_changed', this.onZoomChanged),
|
|
503
|
+
google.maps.event.addListener(map, 'idle', this.onIdle),
|
|
504
|
+
];
|
|
505
|
+
}
|
|
486
506
|
};
|
|
487
507
|
Clusterer.prototype.onRemove = function () {
|
|
488
508
|
// Put all the managed markers back on the map:
|
|
@@ -527,9 +547,10 @@ var Clusterer = /** @class */ (function () {
|
|
|
527
547
|
bounds.extend(position);
|
|
528
548
|
}
|
|
529
549
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
550
|
+
var map = this.getMap();
|
|
551
|
+
if (map !== null && 'fitBounds' in map) {
|
|
552
|
+
map.fitBounds(bounds);
|
|
553
|
+
}
|
|
533
554
|
};
|
|
534
555
|
Clusterer.prototype.getGridSize = function () {
|
|
535
556
|
return this.gridSize;
|
|
@@ -719,27 +740,37 @@ var Clusterer = /** @class */ (function () {
|
|
|
719
740
|
}, 0);
|
|
720
741
|
};
|
|
721
742
|
Clusterer.prototype.getExtendedBounds = function (bounds) {
|
|
722
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
723
|
-
// @ts-ignore
|
|
724
743
|
var projection = this.getProjection();
|
|
725
744
|
// Convert the points to pixels and the extend out by the grid size.
|
|
726
745
|
var trPix = projection.fromLatLngToDivPixel(
|
|
727
746
|
// Turn the bounds into latlng.
|
|
728
747
|
new google.maps.LatLng(bounds.getNorthEast().lat(), bounds.getNorthEast().lng()));
|
|
729
|
-
trPix
|
|
730
|
-
|
|
748
|
+
if (trPix !== null) {
|
|
749
|
+
trPix.x += this.gridSize;
|
|
750
|
+
trPix.y -= this.gridSize;
|
|
751
|
+
}
|
|
731
752
|
var blPix = projection.fromLatLngToDivPixel(
|
|
732
753
|
// Turn the bounds into latlng.
|
|
733
754
|
new google.maps.LatLng(bounds.getSouthWest().lat(), bounds.getSouthWest().lng()));
|
|
734
|
-
blPix
|
|
735
|
-
|
|
755
|
+
if (blPix !== null) {
|
|
756
|
+
blPix.x -= this.gridSize;
|
|
757
|
+
blPix.y += this.gridSize;
|
|
758
|
+
}
|
|
736
759
|
// Extend the bounds to contain the new bounds.
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
760
|
+
if (trPix !== null) {
|
|
761
|
+
// Convert the pixel points back to LatLng nw
|
|
762
|
+
var point1 = projection.fromDivPixelToLatLng(trPix);
|
|
763
|
+
if (point1 !== null) {
|
|
764
|
+
bounds.extend(point1);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
if (blPix !== null) {
|
|
768
|
+
// Convert the pixel points back to LatLng sw
|
|
769
|
+
var point2 = projection.fromDivPixelToLatLng(blPix);
|
|
770
|
+
if (point2 !== null) {
|
|
771
|
+
bounds.extend(point2);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
743
774
|
return bounds;
|
|
744
775
|
};
|
|
745
776
|
Clusterer.prototype.redraw = function () {
|
|
@@ -826,31 +857,21 @@ var Clusterer = /** @class */ (function () {
|
|
|
826
857
|
delete this.timerRefStatic;
|
|
827
858
|
}
|
|
828
859
|
}
|
|
860
|
+
var map = this.getMap();
|
|
861
|
+
var bounds = map !== null && 'getBounds' in map ? map.getBounds() : null;
|
|
862
|
+
var zoom = (map === null || map === void 0 ? void 0 : map.getZoom()) || 0;
|
|
829
863
|
// Get our current map view bounds.
|
|
830
864
|
// Create a new bounds object so we don't affect the map.
|
|
831
865
|
//
|
|
832
866
|
// See Comments 9 & 11 on Issue 3651 relating to this workaround for a Google Maps bug:
|
|
833
|
-
var mapBounds =
|
|
834
|
-
|
|
835
|
-
// @ts-ignore
|
|
836
|
-
this.getMap().getZoom() > 3
|
|
837
|
-
? new google.maps.LatLngBounds(
|
|
838
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
839
|
-
// @ts-ignore
|
|
840
|
-
this.getMap()
|
|
841
|
-
.getBounds()
|
|
842
|
-
.getSouthWest(),
|
|
843
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
844
|
-
// @ts-ignore
|
|
845
|
-
this.getMap()
|
|
846
|
-
.getBounds()
|
|
847
|
-
.getNorthEast())
|
|
867
|
+
var mapBounds = zoom > 3
|
|
868
|
+
? new google.maps.LatLngBounds(bounds === null || bounds === void 0 ? void 0 : bounds.getSouthWest(), bounds === null || bounds === void 0 ? void 0 : bounds.getNorthEast())
|
|
848
869
|
: new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472, -178.48388434375), new google.maps.LatLng(-85.08136444384544, 178.00048865625));
|
|
849
|
-
var
|
|
870
|
+
var extendedMapBounds = this.getExtendedBounds(mapBounds);
|
|
850
871
|
var iLast = Math.min(iFirst + this.batchSize, this.markers.length);
|
|
851
872
|
for (var i = iFirst; i < iLast; i++) {
|
|
852
873
|
var marker = this.markers[i];
|
|
853
|
-
if (!marker.isAdded && this.isMarkerInBounds(marker,
|
|
874
|
+
if (!marker.isAdded && this.isMarkerInBounds(marker, extendedMapBounds) && (!this.ignoreHidden || (this.ignoreHidden && marker.getVisible()))) {
|
|
854
875
|
this.addToClosestCluster(marker);
|
|
855
876
|
}
|
|
856
877
|
}
|
|
@@ -876,19 +897,14 @@ var Clusterer = /** @class */ (function () {
|
|
|
876
897
|
};
|
|
877
898
|
Clusterer.prototype.extend = function (obj1, obj2) {
|
|
878
899
|
return function applyExtend(object) {
|
|
879
|
-
// eslint-disable-next-line guard-for-in
|
|
880
900
|
for (var property in object.prototype) {
|
|
881
|
-
|
|
882
|
-
// @ts-ignore
|
|
883
|
-
this.prototype[property] = object.prototype[property];
|
|
901
|
+
this.prototype.set(property, object.prototype.get(property));
|
|
884
902
|
}
|
|
885
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
886
|
-
// @ts-ignore
|
|
887
903
|
return this;
|
|
888
904
|
}.apply(obj1, [obj2]);
|
|
889
905
|
};
|
|
890
906
|
return Clusterer;
|
|
891
|
-
}());
|
|
907
|
+
}(google.maps.OverlayView));
|
|
892
908
|
|
|
893
909
|
export { Cluster, ClusterIcon, Clusterer };
|
|
894
910
|
//# sourceMappingURL=esm.js.map
|