@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/umd.js
CHANGED
|
@@ -4,68 +4,47 @@
|
|
|
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
|
-
|
|
38
|
-
var ClusterIcon = /** @class */ (function (_super) {
|
|
39
|
-
__extends(ClusterIcon, _super);
|
|
7
|
+
var ClusterIcon = /** @class */ (function () {
|
|
40
8
|
function ClusterIcon(cluster, styles) {
|
|
41
|
-
var _this = _super.call(this) || this;
|
|
42
9
|
cluster.getClusterer().extend(ClusterIcon, google.maps.OverlayView);
|
|
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
|
-
|
|
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
|
+
this.cMouseDownInCluster = null;
|
|
32
|
+
this.cDraggingMapByCluster = null;
|
|
33
|
+
this.timeOut = null;
|
|
34
|
+
this.setMap(cluster.getMap()); // Note: this causes onAdd to be called
|
|
35
|
+
this.onBoundsChanged = this.onBoundsChanged.bind(this);
|
|
36
|
+
this.onMouseDown = this.onMouseDown.bind(this);
|
|
37
|
+
this.onClick = this.onClick.bind(this);
|
|
38
|
+
this.onMouseOver = this.onMouseOver.bind(this);
|
|
39
|
+
this.onMouseOut = this.onMouseOut.bind(this);
|
|
40
|
+
this.onAdd = this.onAdd.bind(this);
|
|
41
|
+
this.onRemove = this.onRemove.bind(this);
|
|
42
|
+
this.draw = this.draw.bind(this);
|
|
43
|
+
this.hide = this.hide.bind(this);
|
|
44
|
+
this.show = this.show.bind(this);
|
|
45
|
+
this.useStyle = this.useStyle.bind(this);
|
|
46
|
+
this.setCenter = this.setCenter.bind(this);
|
|
47
|
+
this.getPosFromLatLng = this.getPosFromLatLng.bind(this);
|
|
69
48
|
}
|
|
70
49
|
ClusterIcon.prototype.onBoundsChanged = function () {
|
|
71
50
|
this.cDraggingMapByCluster = this.cMouseDownInCluster;
|
|
@@ -203,6 +182,7 @@
|
|
|
203
182
|
else {
|
|
204
183
|
divTitle = this.sums.title;
|
|
205
184
|
}
|
|
185
|
+
this.div.className = this.className;
|
|
206
186
|
this.div.style.cursor = 'pointer';
|
|
207
187
|
this.div.style.position = 'absolute';
|
|
208
188
|
this.div.style.top = pos !== null ? "".concat(pos.y, "px") : '0';
|
|
@@ -212,6 +192,8 @@
|
|
|
212
192
|
var img = document.createElement('img');
|
|
213
193
|
img.alt = divTitle;
|
|
214
194
|
img.src = this.url;
|
|
195
|
+
img.width = this.width;
|
|
196
|
+
img.height = this.height;
|
|
215
197
|
img.style.position = 'absolute';
|
|
216
198
|
img.style.top = "".concat(spriteV, "px");
|
|
217
199
|
img.style.left = "".concat(spriteH, "px");
|
|
@@ -271,7 +253,7 @@
|
|
|
271
253
|
return pos;
|
|
272
254
|
};
|
|
273
255
|
return ClusterIcon;
|
|
274
|
-
}(
|
|
256
|
+
}());
|
|
275
257
|
|
|
276
258
|
var Cluster = /** @class */ (function () {
|
|
277
259
|
function Cluster(markerClusterer) {
|
|
@@ -284,6 +266,18 @@
|
|
|
284
266
|
this.center = undefined;
|
|
285
267
|
this.bounds = null;
|
|
286
268
|
this.clusterIcon = new ClusterIcon(this, this.markerClusterer.getStyles());
|
|
269
|
+
this.getSize = this.getSize.bind(this);
|
|
270
|
+
this.getMarkers = this.getMarkers.bind(this);
|
|
271
|
+
this.getCenter = this.getCenter.bind(this);
|
|
272
|
+
this.getMap = this.getMap.bind(this);
|
|
273
|
+
this.getClusterer = this.getClusterer.bind(this);
|
|
274
|
+
this.getBounds = this.getBounds.bind(this);
|
|
275
|
+
this.remove = this.remove.bind(this);
|
|
276
|
+
this.addMarker = this.addMarker.bind(this);
|
|
277
|
+
this.isMarkerInClusterBounds = this.isMarkerInClusterBounds.bind(this);
|
|
278
|
+
this.calculateBounds = this.calculateBounds.bind(this);
|
|
279
|
+
this.updateIcon = this.updateIcon.bind(this);
|
|
280
|
+
this.isMarkerAlreadyAdded = this.isMarkerAlreadyAdded.bind(this);
|
|
287
281
|
}
|
|
288
282
|
Cluster.prototype.getSize = function () {
|
|
289
283
|
return this.markers.length;
|
|
@@ -414,11 +408,12 @@
|
|
|
414
408
|
return Cluster;
|
|
415
409
|
}());
|
|
416
410
|
|
|
411
|
+
/* global google */
|
|
417
412
|
/**
|
|
418
413
|
* Supports up to 9007199254740991 (Number.MAX_SAFE_INTEGER) markers
|
|
419
414
|
* which is not a problem as max array length is 4294967296 (2**32)
|
|
420
415
|
*/
|
|
421
|
-
|
|
416
|
+
function CALCULATOR(markers, numStyles) {
|
|
422
417
|
var count = markers.length;
|
|
423
418
|
var numberOfDigits = count.toString().length;
|
|
424
419
|
var index = Math.min(numberOfDigits, numStyles);
|
|
@@ -427,62 +422,113 @@
|
|
|
427
422
|
index: index,
|
|
428
423
|
title: '',
|
|
429
424
|
};
|
|
430
|
-
}
|
|
425
|
+
}
|
|
431
426
|
var BATCH_SIZE = 2000;
|
|
432
427
|
var BATCH_SIZE_IE = 500;
|
|
433
428
|
var IMAGE_PATH = 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m';
|
|
434
429
|
var IMAGE_EXTENSION = 'png';
|
|
435
430
|
var IMAGE_SIZES = [53, 56, 66, 78, 90];
|
|
436
431
|
var CLUSTERER_CLASS = 'cluster';
|
|
437
|
-
var Clusterer = /** @class */ (function (
|
|
438
|
-
__extends(Clusterer, _super);
|
|
432
|
+
var Clusterer = /** @class */ (function () {
|
|
439
433
|
function Clusterer(map, optMarkers, optOptions) {
|
|
440
434
|
if (optMarkers === void 0) { optMarkers = []; }
|
|
441
435
|
if (optOptions === void 0) { optOptions = {}; }
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
_this.zoomOnClick = true;
|
|
436
|
+
this.extend(Clusterer, google.maps.OverlayView);
|
|
437
|
+
this.markers = [];
|
|
438
|
+
this.clusters = [];
|
|
439
|
+
this.listeners = [];
|
|
440
|
+
this.activeMap = null;
|
|
441
|
+
this.ready = false;
|
|
442
|
+
this.gridSize = optOptions.gridSize || 60;
|
|
443
|
+
this.minClusterSize = optOptions.minimumClusterSize || 2;
|
|
444
|
+
this.maxZoom = optOptions.maxZoom || null;
|
|
445
|
+
this.styles = optOptions.styles || [];
|
|
446
|
+
this.title = optOptions.title || '';
|
|
447
|
+
this.zoomOnClick = true;
|
|
455
448
|
if (optOptions.zoomOnClick !== undefined) {
|
|
456
|
-
|
|
449
|
+
this.zoomOnClick = optOptions.zoomOnClick;
|
|
457
450
|
}
|
|
458
|
-
|
|
451
|
+
this.averageCenter = false;
|
|
459
452
|
if (optOptions.averageCenter !== undefined) {
|
|
460
|
-
|
|
453
|
+
this.averageCenter = optOptions.averageCenter;
|
|
461
454
|
}
|
|
462
|
-
|
|
455
|
+
this.ignoreHidden = false;
|
|
463
456
|
if (optOptions.ignoreHidden !== undefined) {
|
|
464
|
-
|
|
457
|
+
this.ignoreHidden = optOptions.ignoreHidden;
|
|
465
458
|
}
|
|
466
|
-
|
|
459
|
+
this.enableRetinaIcons = false;
|
|
467
460
|
if (optOptions.enableRetinaIcons !== undefined) {
|
|
468
|
-
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
461
|
+
this.enableRetinaIcons = optOptions.enableRetinaIcons;
|
|
462
|
+
}
|
|
463
|
+
this.imagePath = optOptions.imagePath || IMAGE_PATH;
|
|
464
|
+
this.imageExtension = optOptions.imageExtension || IMAGE_EXTENSION;
|
|
465
|
+
this.imageSizes = optOptions.imageSizes || IMAGE_SIZES;
|
|
466
|
+
this.calculator = optOptions.calculator || CALCULATOR;
|
|
467
|
+
this.batchSize = optOptions.batchSize || BATCH_SIZE;
|
|
468
|
+
this.batchSizeIE = optOptions.batchSizeIE || BATCH_SIZE_IE;
|
|
469
|
+
this.clusterClass = optOptions.clusterClass || CLUSTERER_CLASS;
|
|
477
470
|
if (navigator.userAgent.toLowerCase().indexOf('msie') !== -1) {
|
|
478
471
|
// Try to avoid IE timeout when processing a huge number of markers:
|
|
479
|
-
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
472
|
+
this.batchSize = this.batchSizeIE;
|
|
473
|
+
}
|
|
474
|
+
this.timerRefStatic = null;
|
|
475
|
+
this.setupStyles();
|
|
476
|
+
this.addMarkers(optMarkers, true);
|
|
477
|
+
this.setMap(map); // Note: this causes onAdd to be called
|
|
478
|
+
this.onZoomChanged = this.onZoomChanged.bind(this);
|
|
479
|
+
this.onIdle = this.onIdle.bind(this);
|
|
480
|
+
this.onAdd = this.onAdd.bind(this);
|
|
481
|
+
this.onRemove = this.onRemove.bind(this);
|
|
482
|
+
this.draw = this.draw.bind(this);
|
|
483
|
+
this.setupStyles = this.setupStyles.bind(this);
|
|
484
|
+
this.fitMapToMarkers = this.fitMapToMarkers.bind(this);
|
|
485
|
+
this.getGridSize = this.getGridSize.bind(this);
|
|
486
|
+
this.setGridSize = this.setGridSize.bind(this);
|
|
487
|
+
this.getMinimumClusterSize = this.getMinimumClusterSize.bind(this);
|
|
488
|
+
this.setMinimumClusterSize = this.setMinimumClusterSize.bind(this);
|
|
489
|
+
this.getMaxZoom = this.getMaxZoom.bind(this);
|
|
490
|
+
this.setMaxZoom = this.setMaxZoom.bind(this);
|
|
491
|
+
this.getStyles = this.getStyles.bind(this);
|
|
492
|
+
this.setStyles = this.setStyles.bind(this);
|
|
493
|
+
this.getTitle = this.getTitle.bind(this);
|
|
494
|
+
this.setTitle = this.setTitle.bind(this);
|
|
495
|
+
this.getZoomOnClick = this.getZoomOnClick.bind(this);
|
|
496
|
+
this.setZoomOnClick = this.setZoomOnClick.bind(this);
|
|
497
|
+
this.getAverageCenter = this.getAverageCenter.bind(this);
|
|
498
|
+
this.setAverageCenter = this.setAverageCenter.bind(this);
|
|
499
|
+
this.getIgnoreHidden = this.getIgnoreHidden.bind(this);
|
|
500
|
+
this.setIgnoreHidden = this.setIgnoreHidden.bind(this);
|
|
501
|
+
this.getEnableRetinaIcons = this.getEnableRetinaIcons.bind(this);
|
|
502
|
+
this.setEnableRetinaIcons = this.setEnableRetinaIcons.bind(this);
|
|
503
|
+
this.getImageExtension = this.getImageExtension.bind(this);
|
|
504
|
+
this.setImageExtension = this.setImageExtension.bind(this);
|
|
505
|
+
this.getImagePath = this.getImagePath.bind(this);
|
|
506
|
+
this.setImagePath = this.setImagePath.bind(this);
|
|
507
|
+
this.getImageSizes = this.getImageSizes.bind(this);
|
|
508
|
+
this.setImageSizes = this.setImageSizes.bind(this);
|
|
509
|
+
this.getCalculator = this.getCalculator.bind(this);
|
|
510
|
+
this.setCalculator = this.setCalculator.bind(this);
|
|
511
|
+
this.getBatchSizeIE = this.getBatchSizeIE.bind(this);
|
|
512
|
+
this.setBatchSizeIE = this.setBatchSizeIE.bind(this);
|
|
513
|
+
this.getClusterClass = this.getClusterClass.bind(this);
|
|
514
|
+
this.setClusterClass = this.setClusterClass.bind(this);
|
|
515
|
+
this.getMarkers = this.getMarkers.bind(this);
|
|
516
|
+
this.getTotalMarkers = this.getTotalMarkers.bind(this);
|
|
517
|
+
this.getClusters = this.getClusters.bind(this);
|
|
518
|
+
this.getTotalClusters = this.getTotalClusters.bind(this);
|
|
519
|
+
this.addMarker = this.addMarker.bind(this);
|
|
520
|
+
this.addMarkers = this.addMarkers.bind(this);
|
|
521
|
+
this.pushMarkerTo = this.pushMarkerTo.bind(this);
|
|
522
|
+
this.removeMarker = this.removeMarker.bind(this);
|
|
523
|
+
this.removeMarkers = this.removeMarkers.bind(this);
|
|
524
|
+
this.clearMarkers = this.clearMarkers.bind(this);
|
|
525
|
+
this.repaint = this.repaint.bind(this);
|
|
526
|
+
this.getExtendedBounds = this.getExtendedBounds.bind(this);
|
|
527
|
+
this.redraw = this.redraw.bind(this);
|
|
528
|
+
this.resetViewport = this.resetViewport.bind(this);
|
|
529
|
+
this.addToClosestCluster = this.addToClosestCluster.bind(this);
|
|
530
|
+
this.createClusters = this.createClusters.bind(this);
|
|
531
|
+
this.extend = this.extend.bind(this);
|
|
486
532
|
}
|
|
487
533
|
Clusterer.prototype.onZoomChanged = function () {
|
|
488
534
|
var _a, _b;
|
|
@@ -533,15 +579,14 @@
|
|
|
533
579
|
this.activeMap = null;
|
|
534
580
|
this.ready = false;
|
|
535
581
|
};
|
|
536
|
-
|
|
537
|
-
Clusterer.prototype.draw = function () { };
|
|
582
|
+
Clusterer.prototype.draw = function () { return; };
|
|
538
583
|
Clusterer.prototype.setupStyles = function () {
|
|
539
584
|
if (this.styles.length > 0) {
|
|
540
585
|
return;
|
|
541
586
|
}
|
|
542
587
|
for (var i = 0; i < this.imageSizes.length; i++) {
|
|
543
588
|
this.styles.push({
|
|
544
|
-
url: this.imagePath + (i + 1)
|
|
589
|
+
url: "".concat(this.imagePath + (i + 1), ".").concat(this.imageExtension),
|
|
545
590
|
height: this.imageSizes[i],
|
|
546
591
|
width: this.imageSizes[i],
|
|
547
592
|
});
|
|
@@ -913,7 +958,7 @@
|
|
|
913
958
|
}.apply(obj1, [obj2]);
|
|
914
959
|
};
|
|
915
960
|
return Clusterer;
|
|
916
|
-
}(
|
|
961
|
+
}());
|
|
917
962
|
|
|
918
963
|
exports.Cluster = Cluster;
|
|
919
964
|
exports.ClusterIcon = ClusterIcon;
|