@react-google-maps/marker-clusterer 2.11.1 → 2.11.4
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 +149 -104
- 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 +149 -104
- 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 +3 -3
- package/dist/umd.js +149 -104
- 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 +15 -2
- package/src/ClusterIcon.tsx +26 -11
- package/src/Clusterer.tsx +71 -20
package/dist/esm.js
CHANGED
|
@@ -1,65 +1,44 @@
|
|
|
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
|
-
|
|
32
|
-
var ClusterIcon = /** @class */ (function (_super) {
|
|
33
|
-
__extends(ClusterIcon, _super);
|
|
1
|
+
var ClusterIcon = /** @class */ (function () {
|
|
34
2
|
function ClusterIcon(cluster, styles) {
|
|
35
|
-
var _this = _super.call(this) || this;
|
|
36
3
|
cluster.getClusterer().extend(ClusterIcon, google.maps.OverlayView);
|
|
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
|
-
|
|
4
|
+
this.cluster = cluster;
|
|
5
|
+
this.clusterClassName = this.cluster.getClusterer().getClusterClass();
|
|
6
|
+
this.className = this.clusterClassName;
|
|
7
|
+
this.styles = styles;
|
|
8
|
+
this.center = undefined;
|
|
9
|
+
this.div = null;
|
|
10
|
+
this.sums = null;
|
|
11
|
+
this.visible = false;
|
|
12
|
+
this.boundsChangedListener = null;
|
|
13
|
+
this.url = '';
|
|
14
|
+
this.height = 0;
|
|
15
|
+
this.width = 0;
|
|
16
|
+
this.anchorText = [0, 0];
|
|
17
|
+
this.anchorIcon = [0, 0];
|
|
18
|
+
this.textColor = 'black';
|
|
19
|
+
this.textSize = 11;
|
|
20
|
+
this.textDecoration = 'none';
|
|
21
|
+
this.fontWeight = 'bold';
|
|
22
|
+
this.fontStyle = 'normal';
|
|
23
|
+
this.fontFamily = 'Arial,sans-serif';
|
|
24
|
+
this.backgroundPosition = '0 0';
|
|
25
|
+
this.cMouseDownInCluster = null;
|
|
26
|
+
this.cDraggingMapByCluster = null;
|
|
27
|
+
this.timeOut = null;
|
|
28
|
+
this.setMap(cluster.getMap()); // Note: this causes onAdd to be called
|
|
29
|
+
this.onBoundsChanged = this.onBoundsChanged.bind(this);
|
|
30
|
+
this.onMouseDown = this.onMouseDown.bind(this);
|
|
31
|
+
this.onClick = this.onClick.bind(this);
|
|
32
|
+
this.onMouseOver = this.onMouseOver.bind(this);
|
|
33
|
+
this.onMouseOut = this.onMouseOut.bind(this);
|
|
34
|
+
this.onAdd = this.onAdd.bind(this);
|
|
35
|
+
this.onRemove = this.onRemove.bind(this);
|
|
36
|
+
this.draw = this.draw.bind(this);
|
|
37
|
+
this.hide = this.hide.bind(this);
|
|
38
|
+
this.show = this.show.bind(this);
|
|
39
|
+
this.useStyle = this.useStyle.bind(this);
|
|
40
|
+
this.setCenter = this.setCenter.bind(this);
|
|
41
|
+
this.getPosFromLatLng = this.getPosFromLatLng.bind(this);
|
|
63
42
|
}
|
|
64
43
|
ClusterIcon.prototype.onBoundsChanged = function () {
|
|
65
44
|
this.cDraggingMapByCluster = this.cMouseDownInCluster;
|
|
@@ -197,6 +176,7 @@ var ClusterIcon = /** @class */ (function (_super) {
|
|
|
197
176
|
else {
|
|
198
177
|
divTitle = this.sums.title;
|
|
199
178
|
}
|
|
179
|
+
this.div.className = this.className;
|
|
200
180
|
this.div.style.cursor = 'pointer';
|
|
201
181
|
this.div.style.position = 'absolute';
|
|
202
182
|
this.div.style.top = pos !== null ? "".concat(pos.y, "px") : '0';
|
|
@@ -206,6 +186,8 @@ var ClusterIcon = /** @class */ (function (_super) {
|
|
|
206
186
|
var img = document.createElement('img');
|
|
207
187
|
img.alt = divTitle;
|
|
208
188
|
img.src = this.url;
|
|
189
|
+
img.width = this.width;
|
|
190
|
+
img.height = this.height;
|
|
209
191
|
img.style.position = 'absolute';
|
|
210
192
|
img.style.top = "".concat(spriteV, "px");
|
|
211
193
|
img.style.left = "".concat(spriteH, "px");
|
|
@@ -265,7 +247,7 @@ var ClusterIcon = /** @class */ (function (_super) {
|
|
|
265
247
|
return pos;
|
|
266
248
|
};
|
|
267
249
|
return ClusterIcon;
|
|
268
|
-
}(
|
|
250
|
+
}());
|
|
269
251
|
|
|
270
252
|
var Cluster = /** @class */ (function () {
|
|
271
253
|
function Cluster(markerClusterer) {
|
|
@@ -278,6 +260,18 @@ var Cluster = /** @class */ (function () {
|
|
|
278
260
|
this.center = undefined;
|
|
279
261
|
this.bounds = null;
|
|
280
262
|
this.clusterIcon = new ClusterIcon(this, this.markerClusterer.getStyles());
|
|
263
|
+
this.getSize = this.getSize.bind(this);
|
|
264
|
+
this.getMarkers = this.getMarkers.bind(this);
|
|
265
|
+
this.getCenter = this.getCenter.bind(this);
|
|
266
|
+
this.getMap = this.getMap.bind(this);
|
|
267
|
+
this.getClusterer = this.getClusterer.bind(this);
|
|
268
|
+
this.getBounds = this.getBounds.bind(this);
|
|
269
|
+
this.remove = this.remove.bind(this);
|
|
270
|
+
this.addMarker = this.addMarker.bind(this);
|
|
271
|
+
this.isMarkerInClusterBounds = this.isMarkerInClusterBounds.bind(this);
|
|
272
|
+
this.calculateBounds = this.calculateBounds.bind(this);
|
|
273
|
+
this.updateIcon = this.updateIcon.bind(this);
|
|
274
|
+
this.isMarkerAlreadyAdded = this.isMarkerAlreadyAdded.bind(this);
|
|
281
275
|
}
|
|
282
276
|
Cluster.prototype.getSize = function () {
|
|
283
277
|
return this.markers.length;
|
|
@@ -408,11 +402,12 @@ var Cluster = /** @class */ (function () {
|
|
|
408
402
|
return Cluster;
|
|
409
403
|
}());
|
|
410
404
|
|
|
405
|
+
/* global google */
|
|
411
406
|
/**
|
|
412
407
|
* Supports up to 9007199254740991 (Number.MAX_SAFE_INTEGER) markers
|
|
413
408
|
* which is not a problem as max array length is 4294967296 (2**32)
|
|
414
409
|
*/
|
|
415
|
-
|
|
410
|
+
function CALCULATOR(markers, numStyles) {
|
|
416
411
|
var count = markers.length;
|
|
417
412
|
var numberOfDigits = count.toString().length;
|
|
418
413
|
var index = Math.min(numberOfDigits, numStyles);
|
|
@@ -421,62 +416,113 @@ var CALCULATOR = function CALCULATOR(markers, numStyles) {
|
|
|
421
416
|
index: index,
|
|
422
417
|
title: '',
|
|
423
418
|
};
|
|
424
|
-
}
|
|
419
|
+
}
|
|
425
420
|
var BATCH_SIZE = 2000;
|
|
426
421
|
var BATCH_SIZE_IE = 500;
|
|
427
422
|
var IMAGE_PATH = 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m';
|
|
428
423
|
var IMAGE_EXTENSION = 'png';
|
|
429
424
|
var IMAGE_SIZES = [53, 56, 66, 78, 90];
|
|
430
425
|
var CLUSTERER_CLASS = 'cluster';
|
|
431
|
-
var Clusterer = /** @class */ (function (
|
|
432
|
-
__extends(Clusterer, _super);
|
|
426
|
+
var Clusterer = /** @class */ (function () {
|
|
433
427
|
function Clusterer(map, optMarkers, optOptions) {
|
|
434
428
|
if (optMarkers === void 0) { optMarkers = []; }
|
|
435
429
|
if (optOptions === void 0) { optOptions = {}; }
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
_this.zoomOnClick = true;
|
|
430
|
+
this.extend(Clusterer, google.maps.OverlayView);
|
|
431
|
+
this.markers = [];
|
|
432
|
+
this.clusters = [];
|
|
433
|
+
this.listeners = [];
|
|
434
|
+
this.activeMap = null;
|
|
435
|
+
this.ready = false;
|
|
436
|
+
this.gridSize = optOptions.gridSize || 60;
|
|
437
|
+
this.minClusterSize = optOptions.minimumClusterSize || 2;
|
|
438
|
+
this.maxZoom = optOptions.maxZoom || null;
|
|
439
|
+
this.styles = optOptions.styles || [];
|
|
440
|
+
this.title = optOptions.title || '';
|
|
441
|
+
this.zoomOnClick = true;
|
|
449
442
|
if (optOptions.zoomOnClick !== undefined) {
|
|
450
|
-
|
|
443
|
+
this.zoomOnClick = optOptions.zoomOnClick;
|
|
451
444
|
}
|
|
452
|
-
|
|
445
|
+
this.averageCenter = false;
|
|
453
446
|
if (optOptions.averageCenter !== undefined) {
|
|
454
|
-
|
|
447
|
+
this.averageCenter = optOptions.averageCenter;
|
|
455
448
|
}
|
|
456
|
-
|
|
449
|
+
this.ignoreHidden = false;
|
|
457
450
|
if (optOptions.ignoreHidden !== undefined) {
|
|
458
|
-
|
|
451
|
+
this.ignoreHidden = optOptions.ignoreHidden;
|
|
459
452
|
}
|
|
460
|
-
|
|
453
|
+
this.enableRetinaIcons = false;
|
|
461
454
|
if (optOptions.enableRetinaIcons !== undefined) {
|
|
462
|
-
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
455
|
+
this.enableRetinaIcons = optOptions.enableRetinaIcons;
|
|
456
|
+
}
|
|
457
|
+
this.imagePath = optOptions.imagePath || IMAGE_PATH;
|
|
458
|
+
this.imageExtension = optOptions.imageExtension || IMAGE_EXTENSION;
|
|
459
|
+
this.imageSizes = optOptions.imageSizes || IMAGE_SIZES;
|
|
460
|
+
this.calculator = optOptions.calculator || CALCULATOR;
|
|
461
|
+
this.batchSize = optOptions.batchSize || BATCH_SIZE;
|
|
462
|
+
this.batchSizeIE = optOptions.batchSizeIE || BATCH_SIZE_IE;
|
|
463
|
+
this.clusterClass = optOptions.clusterClass || CLUSTERER_CLASS;
|
|
471
464
|
if (navigator.userAgent.toLowerCase().indexOf('msie') !== -1) {
|
|
472
465
|
// Try to avoid IE timeout when processing a huge number of markers:
|
|
473
|
-
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
466
|
+
this.batchSize = this.batchSizeIE;
|
|
467
|
+
}
|
|
468
|
+
this.timerRefStatic = null;
|
|
469
|
+
this.setupStyles();
|
|
470
|
+
this.addMarkers(optMarkers, true);
|
|
471
|
+
this.setMap(map); // Note: this causes onAdd to be called
|
|
472
|
+
this.onZoomChanged = this.onZoomChanged.bind(this);
|
|
473
|
+
this.onIdle = this.onIdle.bind(this);
|
|
474
|
+
this.onAdd = this.onAdd.bind(this);
|
|
475
|
+
this.onRemove = this.onRemove.bind(this);
|
|
476
|
+
this.draw = this.draw.bind(this);
|
|
477
|
+
this.setupStyles = this.setupStyles.bind(this);
|
|
478
|
+
this.fitMapToMarkers = this.fitMapToMarkers.bind(this);
|
|
479
|
+
this.getGridSize = this.getGridSize.bind(this);
|
|
480
|
+
this.setGridSize = this.setGridSize.bind(this);
|
|
481
|
+
this.getMinimumClusterSize = this.getMinimumClusterSize.bind(this);
|
|
482
|
+
this.setMinimumClusterSize = this.setMinimumClusterSize.bind(this);
|
|
483
|
+
this.getMaxZoom = this.getMaxZoom.bind(this);
|
|
484
|
+
this.setMaxZoom = this.setMaxZoom.bind(this);
|
|
485
|
+
this.getStyles = this.getStyles.bind(this);
|
|
486
|
+
this.setStyles = this.setStyles.bind(this);
|
|
487
|
+
this.getTitle = this.getTitle.bind(this);
|
|
488
|
+
this.setTitle = this.setTitle.bind(this);
|
|
489
|
+
this.getZoomOnClick = this.getZoomOnClick.bind(this);
|
|
490
|
+
this.setZoomOnClick = this.setZoomOnClick.bind(this);
|
|
491
|
+
this.getAverageCenter = this.getAverageCenter.bind(this);
|
|
492
|
+
this.setAverageCenter = this.setAverageCenter.bind(this);
|
|
493
|
+
this.getIgnoreHidden = this.getIgnoreHidden.bind(this);
|
|
494
|
+
this.setIgnoreHidden = this.setIgnoreHidden.bind(this);
|
|
495
|
+
this.getEnableRetinaIcons = this.getEnableRetinaIcons.bind(this);
|
|
496
|
+
this.setEnableRetinaIcons = this.setEnableRetinaIcons.bind(this);
|
|
497
|
+
this.getImageExtension = this.getImageExtension.bind(this);
|
|
498
|
+
this.setImageExtension = this.setImageExtension.bind(this);
|
|
499
|
+
this.getImagePath = this.getImagePath.bind(this);
|
|
500
|
+
this.setImagePath = this.setImagePath.bind(this);
|
|
501
|
+
this.getImageSizes = this.getImageSizes.bind(this);
|
|
502
|
+
this.setImageSizes = this.setImageSizes.bind(this);
|
|
503
|
+
this.getCalculator = this.getCalculator.bind(this);
|
|
504
|
+
this.setCalculator = this.setCalculator.bind(this);
|
|
505
|
+
this.getBatchSizeIE = this.getBatchSizeIE.bind(this);
|
|
506
|
+
this.setBatchSizeIE = this.setBatchSizeIE.bind(this);
|
|
507
|
+
this.getClusterClass = this.getClusterClass.bind(this);
|
|
508
|
+
this.setClusterClass = this.setClusterClass.bind(this);
|
|
509
|
+
this.getMarkers = this.getMarkers.bind(this);
|
|
510
|
+
this.getTotalMarkers = this.getTotalMarkers.bind(this);
|
|
511
|
+
this.getClusters = this.getClusters.bind(this);
|
|
512
|
+
this.getTotalClusters = this.getTotalClusters.bind(this);
|
|
513
|
+
this.addMarker = this.addMarker.bind(this);
|
|
514
|
+
this.addMarkers = this.addMarkers.bind(this);
|
|
515
|
+
this.pushMarkerTo = this.pushMarkerTo.bind(this);
|
|
516
|
+
this.removeMarker = this.removeMarker.bind(this);
|
|
517
|
+
this.removeMarkers = this.removeMarkers.bind(this);
|
|
518
|
+
this.clearMarkers = this.clearMarkers.bind(this);
|
|
519
|
+
this.repaint = this.repaint.bind(this);
|
|
520
|
+
this.getExtendedBounds = this.getExtendedBounds.bind(this);
|
|
521
|
+
this.redraw = this.redraw.bind(this);
|
|
522
|
+
this.resetViewport = this.resetViewport.bind(this);
|
|
523
|
+
this.addToClosestCluster = this.addToClosestCluster.bind(this);
|
|
524
|
+
this.createClusters = this.createClusters.bind(this);
|
|
525
|
+
this.extend = this.extend.bind(this);
|
|
480
526
|
}
|
|
481
527
|
Clusterer.prototype.onZoomChanged = function () {
|
|
482
528
|
var _a, _b;
|
|
@@ -527,15 +573,14 @@ var Clusterer = /** @class */ (function (_super) {
|
|
|
527
573
|
this.activeMap = null;
|
|
528
574
|
this.ready = false;
|
|
529
575
|
};
|
|
530
|
-
|
|
531
|
-
Clusterer.prototype.draw = function () { };
|
|
576
|
+
Clusterer.prototype.draw = function () { return; };
|
|
532
577
|
Clusterer.prototype.setupStyles = function () {
|
|
533
578
|
if (this.styles.length > 0) {
|
|
534
579
|
return;
|
|
535
580
|
}
|
|
536
581
|
for (var i = 0; i < this.imageSizes.length; i++) {
|
|
537
582
|
this.styles.push({
|
|
538
|
-
url: this.imagePath + (i + 1)
|
|
583
|
+
url: "".concat(this.imagePath + (i + 1), ".").concat(this.imageExtension),
|
|
539
584
|
height: this.imageSizes[i],
|
|
540
585
|
width: this.imageSizes[i],
|
|
541
586
|
});
|
|
@@ -907,7 +952,7 @@ var Clusterer = /** @class */ (function (_super) {
|
|
|
907
952
|
}.apply(obj1, [obj2]);
|
|
908
953
|
};
|
|
909
954
|
return Clusterer;
|
|
910
|
-
}(
|
|
955
|
+
}());
|
|
911
956
|
|
|
912
957
|
export { Cluster, ClusterIcon, Clusterer };
|
|
913
958
|
//# sourceMappingURL=esm.js.map
|