@react-google-maps/marker-clusterer 2.11.0 → 2.11.3
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 +98 -141
- 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 +98 -141
- 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 +5 -5
- package/dist/umd.js +98 -141
- 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 +6 -10
- package/src/ClusterIcon.tsx +44 -37
- package/src/Clusterer.tsx +22 -25
package/dist/esm.js
CHANGED
|
@@ -1,65 +1,31 @@
|
|
|
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
|
-
return _this;
|
|
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
|
|
63
29
|
}
|
|
64
30
|
ClusterIcon.prototype.onBoundsChanged = function () {
|
|
65
31
|
this.cDraggingMapByCluster = this.cMouseDownInCluster;
|
|
@@ -86,22 +52,23 @@ var ClusterIcon = /** @class */ (function (_super) {
|
|
|
86
52
|
// Zoom into the cluster.
|
|
87
53
|
var maxZoom_1 = markerClusterer_1.getMaxZoom();
|
|
88
54
|
var bounds_1 = this.cluster.getBounds();
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
55
|
+
var map = markerClusterer_1.getMap();
|
|
56
|
+
if (map !== null && 'fitBounds' in map) {
|
|
57
|
+
map.fitBounds(bounds_1);
|
|
58
|
+
}
|
|
92
59
|
// There is a fix for Issue 170 here:
|
|
93
60
|
this.timeOut = window.setTimeout(function () {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
61
|
+
var map = markerClusterer_1.getMap();
|
|
62
|
+
if (map !== null) {
|
|
63
|
+
if ('fitBounds' in map) {
|
|
64
|
+
map.fitBounds(bounds_1);
|
|
65
|
+
}
|
|
66
|
+
var zoom = map.getZoom() || 0;
|
|
67
|
+
// Don't zoom beyond the max zoom level
|
|
68
|
+
if (maxZoom_1 !== null &&
|
|
69
|
+
zoom > maxZoom_1) {
|
|
70
|
+
map.setZoom(maxZoom_1 + 1);
|
|
71
|
+
}
|
|
105
72
|
}
|
|
106
73
|
}, 100);
|
|
107
74
|
}
|
|
@@ -131,23 +98,22 @@ var ClusterIcon = /** @class */ (function (_super) {
|
|
|
131
98
|
google.maps.event.trigger(this.cluster.getClusterer(), 'mouseout', this.cluster);
|
|
132
99
|
};
|
|
133
100
|
ClusterIcon.prototype.onAdd = function () {
|
|
101
|
+
var _a;
|
|
134
102
|
this.div = document.createElement('div');
|
|
135
103
|
this.div.className = this.className;
|
|
136
104
|
if (this.visible) {
|
|
137
105
|
this.show();
|
|
138
106
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
this.div.addEventListener('mouseover', this.onMouseOver);
|
|
150
|
-
this.div.addEventListener('mouseout', this.onMouseOut);
|
|
107
|
+
(_a = this.getPanes()) === null || _a === void 0 ? void 0 : _a.overlayMouseTarget.appendChild(this.div);
|
|
108
|
+
var map = this.getMap();
|
|
109
|
+
if (map !== null) {
|
|
110
|
+
// Fix for Issue 157
|
|
111
|
+
this.boundsChangedListener = google.maps.event.addListener(map, 'bounds_changed', this.onBoundsChanged);
|
|
112
|
+
this.div.addEventListener('mousedown', this.onMouseDown);
|
|
113
|
+
this.div.addEventListener('click', this.onClick);
|
|
114
|
+
this.div.addEventListener('mouseover', this.onMouseOver);
|
|
115
|
+
this.div.addEventListener('mouseout', this.onMouseOut);
|
|
116
|
+
}
|
|
151
117
|
};
|
|
152
118
|
ClusterIcon.prototype.onRemove = function () {
|
|
153
119
|
if (this.div && this.div.parentNode) {
|
|
@@ -265,13 +231,11 @@ var ClusterIcon = /** @class */ (function (_super) {
|
|
|
265
231
|
return pos;
|
|
266
232
|
};
|
|
267
233
|
return ClusterIcon;
|
|
268
|
-
}(
|
|
234
|
+
}());
|
|
269
235
|
|
|
270
236
|
var Cluster = /** @class */ (function () {
|
|
271
237
|
function Cluster(markerClusterer) {
|
|
272
238
|
this.markerClusterer = markerClusterer;
|
|
273
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
274
|
-
// @ts-ignore
|
|
275
239
|
this.map = this.markerClusterer.getMap();
|
|
276
240
|
this.gridSize = this.markerClusterer.getGridSize();
|
|
277
241
|
this.minClusterSize = this.markerClusterer.getMinimumClusterSize();
|
|
@@ -308,8 +272,6 @@ var Cluster = /** @class */ (function () {
|
|
|
308
272
|
return bounds;
|
|
309
273
|
};
|
|
310
274
|
Cluster.prototype.remove = function () {
|
|
311
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
312
|
-
// @ts-ignore
|
|
313
275
|
this.clusterIcon.setMap(null);
|
|
314
276
|
this.markers = [];
|
|
315
277
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -317,6 +279,7 @@ var Cluster = /** @class */ (function () {
|
|
|
317
279
|
delete this.markers;
|
|
318
280
|
};
|
|
319
281
|
Cluster.prototype.addMarker = function (marker) {
|
|
282
|
+
var _a;
|
|
320
283
|
if (this.isMarkerAlreadyAdded(marker)) {
|
|
321
284
|
return false;
|
|
322
285
|
}
|
|
@@ -341,7 +304,7 @@ var Cluster = /** @class */ (function () {
|
|
|
341
304
|
this.markers.push(marker);
|
|
342
305
|
var mCount = this.markers.length;
|
|
343
306
|
var maxZoom = this.markerClusterer.getMaxZoom();
|
|
344
|
-
var zoom = this.map.getZoom();
|
|
307
|
+
var zoom = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom();
|
|
345
308
|
if (maxZoom !== null && typeof zoom !== 'undefined' && zoom > maxZoom) {
|
|
346
309
|
// Zoomed in past max zoom, so show the marker.
|
|
347
310
|
if (marker.getMap() !== this.map) {
|
|
@@ -378,9 +341,10 @@ var Cluster = /** @class */ (function () {
|
|
|
378
341
|
this.bounds = this.markerClusterer.getExtendedBounds(new google.maps.LatLngBounds(this.center, this.center));
|
|
379
342
|
};
|
|
380
343
|
Cluster.prototype.updateIcon = function () {
|
|
344
|
+
var _a;
|
|
381
345
|
var mCount = this.markers.length;
|
|
382
346
|
var maxZoom = this.markerClusterer.getMaxZoom();
|
|
383
|
-
var zoom = this.map.getZoom();
|
|
347
|
+
var zoom = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getZoom();
|
|
384
348
|
if (maxZoom !== null && typeof zoom !== 'undefined' && zoom > maxZoom) {
|
|
385
349
|
this.clusterIcon.hide();
|
|
386
350
|
return;
|
|
@@ -410,6 +374,7 @@ var Cluster = /** @class */ (function () {
|
|
|
410
374
|
return Cluster;
|
|
411
375
|
}());
|
|
412
376
|
|
|
377
|
+
/* global google */
|
|
413
378
|
/**
|
|
414
379
|
* Supports up to 9007199254740991 (Number.MAX_SAFE_INTEGER) markers
|
|
415
380
|
* which is not a problem as max array length is 4294967296 (2**32)
|
|
@@ -430,57 +395,52 @@ var IMAGE_PATH = 'https://developers.google.com/maps/documentation/javascript/ex
|
|
|
430
395
|
var IMAGE_EXTENSION = 'png';
|
|
431
396
|
var IMAGE_SIZES = [53, 56, 66, 78, 90];
|
|
432
397
|
var CLUSTERER_CLASS = 'cluster';
|
|
433
|
-
var Clusterer = /** @class */ (function (
|
|
434
|
-
__extends(Clusterer, _super);
|
|
398
|
+
var Clusterer = /** @class */ (function () {
|
|
435
399
|
function Clusterer(map, optMarkers, optOptions) {
|
|
436
400
|
if (optMarkers === void 0) { optMarkers = []; }
|
|
437
401
|
if (optOptions === void 0) { optOptions = {}; }
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
_this.zoomOnClick = true;
|
|
402
|
+
this.extend(Clusterer, google.maps.OverlayView);
|
|
403
|
+
this.markers = [];
|
|
404
|
+
this.clusters = [];
|
|
405
|
+
this.listeners = [];
|
|
406
|
+
this.activeMap = null;
|
|
407
|
+
this.ready = false;
|
|
408
|
+
this.gridSize = optOptions.gridSize || 60;
|
|
409
|
+
this.minClusterSize = optOptions.minimumClusterSize || 2;
|
|
410
|
+
this.maxZoom = optOptions.maxZoom || null;
|
|
411
|
+
this.styles = optOptions.styles || [];
|
|
412
|
+
this.title = optOptions.title || '';
|
|
413
|
+
this.zoomOnClick = true;
|
|
451
414
|
if (optOptions.zoomOnClick !== undefined) {
|
|
452
|
-
|
|
415
|
+
this.zoomOnClick = optOptions.zoomOnClick;
|
|
453
416
|
}
|
|
454
|
-
|
|
417
|
+
this.averageCenter = false;
|
|
455
418
|
if (optOptions.averageCenter !== undefined) {
|
|
456
|
-
|
|
419
|
+
this.averageCenter = optOptions.averageCenter;
|
|
457
420
|
}
|
|
458
|
-
|
|
421
|
+
this.ignoreHidden = false;
|
|
459
422
|
if (optOptions.ignoreHidden !== undefined) {
|
|
460
|
-
|
|
423
|
+
this.ignoreHidden = optOptions.ignoreHidden;
|
|
461
424
|
}
|
|
462
|
-
|
|
425
|
+
this.enableRetinaIcons = false;
|
|
463
426
|
if (optOptions.enableRetinaIcons !== undefined) {
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
427
|
+
this.enableRetinaIcons = optOptions.enableRetinaIcons;
|
|
428
|
+
}
|
|
429
|
+
this.imagePath = optOptions.imagePath || IMAGE_PATH;
|
|
430
|
+
this.imageExtension = optOptions.imageExtension || IMAGE_EXTENSION;
|
|
431
|
+
this.imageSizes = optOptions.imageSizes || IMAGE_SIZES;
|
|
432
|
+
this.calculator = optOptions.calculator || CALCULATOR;
|
|
433
|
+
this.batchSize = optOptions.batchSize || BATCH_SIZE;
|
|
434
|
+
this.batchSizeIE = optOptions.batchSizeIE || BATCH_SIZE_IE;
|
|
435
|
+
this.clusterClass = optOptions.clusterClass || CLUSTERER_CLASS;
|
|
473
436
|
if (navigator.userAgent.toLowerCase().indexOf('msie') !== -1) {
|
|
474
437
|
// Try to avoid IE timeout when processing a huge number of markers:
|
|
475
|
-
|
|
438
|
+
this.batchSize = this.batchSizeIE;
|
|
476
439
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
//
|
|
481
|
-
// @ts-ignore
|
|
482
|
-
_this.setMap(map); // Note: this causes onAdd to be called
|
|
483
|
-
return _this;
|
|
440
|
+
this.timerRefStatic = null;
|
|
441
|
+
this.setupStyles();
|
|
442
|
+
this.addMarkers(optMarkers, true);
|
|
443
|
+
this.setMap(map); // Note: this causes onAdd to be called
|
|
484
444
|
}
|
|
485
445
|
Clusterer.prototype.onZoomChanged = function () {
|
|
486
446
|
var _a, _b;
|
|
@@ -554,9 +514,10 @@ var Clusterer = /** @class */ (function (_super) {
|
|
|
554
514
|
bounds.extend(position);
|
|
555
515
|
}
|
|
556
516
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
517
|
+
var map = this.getMap();
|
|
518
|
+
if (map !== null && 'fitBounds' in map) {
|
|
519
|
+
map.fitBounds(bounds);
|
|
520
|
+
}
|
|
560
521
|
};
|
|
561
522
|
Clusterer.prototype.getGridSize = function () {
|
|
562
523
|
return this.gridSize;
|
|
@@ -746,8 +707,6 @@ var Clusterer = /** @class */ (function (_super) {
|
|
|
746
707
|
}, 0);
|
|
747
708
|
};
|
|
748
709
|
Clusterer.prototype.getExtendedBounds = function (bounds) {
|
|
749
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
750
|
-
// @ts-ignore
|
|
751
710
|
var projection = this.getProjection();
|
|
752
711
|
// Convert the points to pixels and the extend out by the grid size.
|
|
753
712
|
var trPix = projection.fromLatLngToDivPixel(
|
|
@@ -867,14 +826,12 @@ var Clusterer = /** @class */ (function (_super) {
|
|
|
867
826
|
}
|
|
868
827
|
var map = this.getMap();
|
|
869
828
|
var bounds = map !== null && 'getBounds' in map ? map.getBounds() : null;
|
|
829
|
+
var zoom = (map === null || map === void 0 ? void 0 : map.getZoom()) || 0;
|
|
870
830
|
// Get our current map view bounds.
|
|
871
831
|
// Create a new bounds object so we don't affect the map.
|
|
872
832
|
//
|
|
873
833
|
// See Comments 9 & 11 on Issue 3651 relating to this workaround for a Google Maps bug:
|
|
874
|
-
var mapBounds =
|
|
875
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
876
|
-
// @ts-ignore
|
|
877
|
-
map.getZoom() > 3
|
|
834
|
+
var mapBounds = zoom > 3
|
|
878
835
|
? new google.maps.LatLngBounds(bounds === null || bounds === void 0 ? void 0 : bounds.getSouthWest(), bounds === null || bounds === void 0 ? void 0 : bounds.getNorthEast())
|
|
879
836
|
: new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472, -178.48388434375), new google.maps.LatLng(-85.08136444384544, 178.00048865625));
|
|
880
837
|
var extendedMapBounds = this.getExtendedBounds(mapBounds);
|
|
@@ -914,7 +871,7 @@ var Clusterer = /** @class */ (function (_super) {
|
|
|
914
871
|
}.apply(obj1, [obj2]);
|
|
915
872
|
};
|
|
916
873
|
return Clusterer;
|
|
917
|
-
}(
|
|
874
|
+
}());
|
|
918
875
|
|
|
919
876
|
export { Cluster, ClusterIcon, Clusterer };
|
|
920
877
|
//# sourceMappingURL=esm.js.map
|