@react-google-maps/marker-clusterer 2.6.0 → 2.8.0
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 +40 -119
- 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 +40 -119
- 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 +15 -16
- package/dist/umd.js +40 -119
- 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 +33 -25
- package/src/Cluster.tsx +0 -2
- package/src/ClusterIcon.tsx +34 -97
- package/src/Clusterer.tsx +2 -20
- package/src/__tests__/clusterer.test.ts +4 -0
- package/src/types.tsx +16 -16
package/dist/cjs.js
CHANGED
|
@@ -26,7 +26,6 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
26
26
|
this.fontStyle = 'normal';
|
|
27
27
|
this.fontFamily = 'Arial,sans-serif';
|
|
28
28
|
this.backgroundPosition = '0 0';
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
30
29
|
// @ts-ignore
|
|
31
30
|
this.setMap(cluster.getMap()); // Note: this causes onAdd to be called
|
|
32
31
|
}
|
|
@@ -39,12 +38,10 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
39
38
|
if (this.visible) {
|
|
40
39
|
this.show();
|
|
41
40
|
}
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
43
41
|
// @ts-ignore
|
|
44
42
|
this.getPanes().overlayMouseTarget.appendChild(this.div);
|
|
45
43
|
// Fix for Issue 157
|
|
46
44
|
this.boundsChangedListener = google.maps.event.addListener(
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
48
45
|
// @ts-ignore
|
|
49
46
|
this.getMap(), 'boundschanged', function boundsChanged() {
|
|
50
47
|
cDraggingMapByCluster = cMouseDownInCluster;
|
|
@@ -53,10 +50,7 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
53
50
|
cMouseDownInCluster = true;
|
|
54
51
|
cDraggingMapByCluster = false;
|
|
55
52
|
});
|
|
56
|
-
|
|
57
|
-
google.maps.event.addDomListener(this.div, 'click',
|
|
58
|
-
// eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
|
|
59
|
-
function (event) {
|
|
53
|
+
google.maps.event.addDomListener(this.div, 'click', function (event) {
|
|
60
54
|
cMouseDownInCluster = false;
|
|
61
55
|
if (!cDraggingMapByCluster) {
|
|
62
56
|
var markerClusterer_1 = _this.cluster.getClusterer();
|
|
@@ -74,19 +68,15 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
74
68
|
// Zoom into the cluster.
|
|
75
69
|
var maxZoom_1 = markerClusterer_1.getMaxZoom();
|
|
76
70
|
var bounds_1 = _this.cluster.getBounds();
|
|
77
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
78
71
|
// @ts-ignore
|
|
79
72
|
markerClusterer_1.getMap().fitBounds(bounds_1);
|
|
80
73
|
// There is a fix for Issue 170 here:
|
|
81
74
|
setTimeout(function timeout() {
|
|
82
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
83
75
|
// @ts-ignore
|
|
84
76
|
markerClusterer_1.getMap().fitBounds(bounds_1);
|
|
85
77
|
// Don't zoom beyond the max zoom level
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
87
78
|
// @ts-ignore
|
|
88
79
|
if (maxZoom_1 !== null && markerClusterer_1.getMap().getZoom() > maxZoom_1) {
|
|
89
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
90
80
|
// @ts-ignore
|
|
91
81
|
markerClusterer_1.getMap().setZoom(maxZoom_1 + 1);
|
|
92
82
|
}
|
|
@@ -99,9 +89,7 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
99
89
|
}
|
|
100
90
|
}
|
|
101
91
|
});
|
|
102
|
-
google.maps.event.addDomListener(this.div, 'mouseover',
|
|
103
|
-
// eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
|
|
104
|
-
function () {
|
|
92
|
+
google.maps.event.addDomListener(this.div, 'mouseover', function () {
|
|
105
93
|
/**
|
|
106
94
|
* This event is fired when the mouse moves over a cluster marker.
|
|
107
95
|
* @name MarkerClusterer#mouseover
|
|
@@ -110,10 +98,7 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
110
98
|
*/
|
|
111
99
|
google.maps.event.trigger(_this.cluster.getClusterer(), 'mouseover', _this.cluster);
|
|
112
100
|
});
|
|
113
|
-
|
|
114
|
-
google.maps.event.addDomListener(this.div, 'mouseout',
|
|
115
|
-
// eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
|
|
116
|
-
function () {
|
|
101
|
+
google.maps.event.addDomListener(this.div, 'mouseout', function () {
|
|
117
102
|
/**
|
|
118
103
|
* This event is fired when the mouse moves out of a cluster marker.
|
|
119
104
|
* @name MarkerClusterer#mouseout
|
|
@@ -148,8 +133,9 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
148
133
|
this.visible = false;
|
|
149
134
|
};
|
|
150
135
|
ClusterIcon.prototype.show = function () {
|
|
136
|
+
var _a;
|
|
151
137
|
if (this.div && this.center) {
|
|
152
|
-
var
|
|
138
|
+
var divTitle = '';
|
|
153
139
|
// NOTE: values must be specified in px units
|
|
154
140
|
var bp = this.backgroundPosition.split(' ');
|
|
155
141
|
var spriteH = parseInt(bp[0].replace(/^\s+|\s+$/g, ''), 10);
|
|
@@ -161,72 +147,38 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
161
147
|
else {
|
|
162
148
|
divTitle = this.sums.title;
|
|
163
149
|
}
|
|
164
|
-
this.div.style.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
//@ts-ignore
|
|
150
|
+
this.div.style.cursor = 'pointer';
|
|
151
|
+
this.div.style.position = 'absolute';
|
|
152
|
+
this.div.style.top = "".concat(pos.y, "px");
|
|
153
|
+
this.div.style.left = "".concat(pos.x, "px");
|
|
154
|
+
this.div.style.width = "".concat(this.width, "px");
|
|
155
|
+
this.div.style.height = "".concat(this.height, "px");
|
|
156
|
+
var img = document.createElement('img');
|
|
157
|
+
img.alt = divTitle;
|
|
158
|
+
img.src = this.url;
|
|
159
|
+
img.style.position = 'absolute';
|
|
160
|
+
img.style.top = "".concat(spriteV, "px");
|
|
161
|
+
img.style.left = "".concat(spriteH, "px");
|
|
177
162
|
if (!this.cluster.getClusterer().enableRetinaIcons) {
|
|
178
|
-
img
|
|
179
|
-
'clip: rect(' +
|
|
180
|
-
-1 * spriteV +
|
|
181
|
-
'px, ' +
|
|
182
|
-
(-1 * spriteH + this.width) +
|
|
183
|
-
'px, ' +
|
|
184
|
-
(-1 * spriteV + this.height) +
|
|
185
|
-
'px, ' +
|
|
186
|
-
-1 * spriteH +
|
|
187
|
-
'px);';
|
|
163
|
+
img.style.clip = "rect(-".concat(spriteV, "px, -").concat(spriteH + this.width, "px, -").concat(spriteV + this.height, ", -").concat(spriteH, ")");
|
|
188
164
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
'font-family: ' +
|
|
207
|
-
this.fontFamily +
|
|
208
|
-
';' +
|
|
209
|
-
'font-weight: ' +
|
|
210
|
-
this.fontWeight +
|
|
211
|
-
';' +
|
|
212
|
-
'font-style: ' +
|
|
213
|
-
this.fontStyle +
|
|
214
|
-
';' +
|
|
215
|
-
'text-decoration: ' +
|
|
216
|
-
this.textDecoration +
|
|
217
|
-
';' +
|
|
218
|
-
'text-align: center;' +
|
|
219
|
-
'width: ' +
|
|
220
|
-
this.width +
|
|
221
|
-
'px;' +
|
|
222
|
-
'line-height:' +
|
|
223
|
-
this.height +
|
|
224
|
-
'px;' +
|
|
225
|
-
"'>" +
|
|
226
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
227
|
-
// @ts-ignore
|
|
228
|
-
this.sums.text +
|
|
229
|
-
'</div>';
|
|
165
|
+
var textElm = document.createElement('div');
|
|
166
|
+
textElm.style.position = 'absolute';
|
|
167
|
+
textElm.style.top = "".concat(this.anchorText[0], "px");
|
|
168
|
+
textElm.style.left = "".concat(this.anchorText[1], "px");
|
|
169
|
+
textElm.style.color = this.textColor;
|
|
170
|
+
textElm.style.fontSize = "".concat(this.textSize, "px");
|
|
171
|
+
textElm.style.fontFamily = this.fontFamily;
|
|
172
|
+
textElm.style.fontWeight = this.fontWeight;
|
|
173
|
+
textElm.style.fontStyle = this.fontStyle;
|
|
174
|
+
textElm.style.textDecoration = this.textDecoration;
|
|
175
|
+
textElm.style.textAlign = 'center';
|
|
176
|
+
textElm.style.width = "".concat(this.width, "px");
|
|
177
|
+
textElm.style.lineHeight = "".concat(this.height, "px");
|
|
178
|
+
textElm.innerText = "".concat((_a = this.sums) === null || _a === void 0 ? void 0 : _a.text);
|
|
179
|
+
this.div.innerHTML = '';
|
|
180
|
+
this.div.appendChild(img);
|
|
181
|
+
this.div.appendChild(textElm);
|
|
230
182
|
this.div.title = divTitle;
|
|
231
183
|
this.div.style.display = '';
|
|
232
184
|
}
|
|
@@ -240,7 +192,7 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
240
192
|
this.height = style.height;
|
|
241
193
|
this.width = style.width;
|
|
242
194
|
if (style.className)
|
|
243
|
-
this.className = this.clusterClassName
|
|
195
|
+
this.className = "".concat(this.clusterClassName, " ").concat(style.className);
|
|
244
196
|
this.anchorText = style.anchorText || [0, 0];
|
|
245
197
|
this.anchorIcon = style.anchorIcon || [this.height / 2, this.width / 2];
|
|
246
198
|
this.textColor = style.textColor || 'black';
|
|
@@ -254,15 +206,7 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
254
206
|
ClusterIcon.prototype.setCenter = function (center) {
|
|
255
207
|
this.center = center;
|
|
256
208
|
};
|
|
257
|
-
ClusterIcon.prototype.createCss = function (pos) {
|
|
258
|
-
var style = [];
|
|
259
|
-
style.push('cursor: pointer;');
|
|
260
|
-
style.push('position: absolute; top: ' + pos.y + 'px; left: ' + pos.x + 'px;');
|
|
261
|
-
style.push('width: ' + this.width + 'px; height: ' + this.height + 'px;');
|
|
262
|
-
return style.join('');
|
|
263
|
-
};
|
|
264
209
|
ClusterIcon.prototype.getPosFromLatLng = function (latlng) {
|
|
265
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
266
210
|
// @ts-ignore
|
|
267
211
|
var pos = this.getProjection().fromLatLngToDivPixel(latlng);
|
|
268
212
|
pos.x -= this.anchorIcon[1];
|
|
@@ -277,7 +221,6 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
277
221
|
var Cluster = /** @class */ (function () {
|
|
278
222
|
function Cluster(markerClusterer) {
|
|
279
223
|
this.markerClusterer = markerClusterer;
|
|
280
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
281
224
|
// @ts-ignore
|
|
282
225
|
this.map = this.markerClusterer.getMap();
|
|
283
226
|
this.gridSize = this.markerClusterer.getGridSize();
|
|
@@ -315,7 +258,6 @@ var Cluster = /** @class */ (function () {
|
|
|
315
258
|
return bounds;
|
|
316
259
|
};
|
|
317
260
|
Cluster.prototype.remove = function () {
|
|
318
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
319
261
|
// @ts-ignore
|
|
320
262
|
this.clusterIcon.setMap(null);
|
|
321
263
|
this.markers = [];
|
|
@@ -484,13 +426,11 @@ var Clusterer = /** @class */ (function () {
|
|
|
484
426
|
this.timerRefStatic = null;
|
|
485
427
|
this.setupStyles();
|
|
486
428
|
this.addMarkers(optMarkers, true);
|
|
487
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
488
429
|
// @ts-ignore
|
|
489
430
|
this.setMap(map); // Note: this causes onAdd to be called
|
|
490
431
|
}
|
|
491
432
|
Clusterer.prototype.onAdd = function () {
|
|
492
433
|
var _this = this;
|
|
493
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
494
434
|
// @ts-ignore
|
|
495
435
|
this.activeMap = this.getMap();
|
|
496
436
|
this.ready = true;
|
|
@@ -498,11 +438,8 @@ var Clusterer = /** @class */ (function () {
|
|
|
498
438
|
// Add the map event listeners
|
|
499
439
|
this.listeners = [
|
|
500
440
|
google.maps.event.addListener(
|
|
501
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
502
441
|
// @ts-ignore
|
|
503
|
-
this.getMap(), 'zoom_changed',
|
|
504
|
-
// eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
|
|
505
|
-
function () {
|
|
442
|
+
this.getMap(), 'zoom_changed', function () {
|
|
506
443
|
_this.resetViewport(false);
|
|
507
444
|
// Workaround for this Google bug: when map is at level 0 and "-" of
|
|
508
445
|
// zoom slider is clicked, a "zoom_changed" event is fired even though
|
|
@@ -510,26 +447,20 @@ var Clusterer = /** @class */ (function () {
|
|
|
510
447
|
// event is triggered so the cluster markers that have been removed
|
|
511
448
|
// do not get redrawn. Same goes for a zoom in at maxZoom.
|
|
512
449
|
if (
|
|
513
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
514
450
|
// @ts-ignore
|
|
515
451
|
_this.getMap().getZoom() === (_this.get('minZoom') || 0) ||
|
|
516
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
517
452
|
// @ts-ignore
|
|
518
453
|
_this.getMap().getZoom() === _this.get('maxZoom')) {
|
|
519
454
|
google.maps.event.trigger(_this, 'idle');
|
|
520
455
|
}
|
|
521
456
|
}),
|
|
522
457
|
google.maps.event.addListener(
|
|
523
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
524
458
|
// @ts-ignore
|
|
525
|
-
this.getMap(), 'idle',
|
|
526
|
-
// eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
|
|
527
|
-
function () {
|
|
459
|
+
this.getMap(), 'idle', function () {
|
|
528
460
|
_this.redraw();
|
|
529
461
|
}),
|
|
530
462
|
];
|
|
531
463
|
};
|
|
532
|
-
// eslint-disable-next-line @getify/proper-arrows/this
|
|
533
464
|
Clusterer.prototype.onRemove = function () {
|
|
534
465
|
// Put all the managed markers back on the map:
|
|
535
466
|
for (var i = 0; i < this.markers.length; i++) {
|
|
@@ -573,7 +504,6 @@ var Clusterer = /** @class */ (function () {
|
|
|
573
504
|
bounds.extend(position);
|
|
574
505
|
}
|
|
575
506
|
}
|
|
576
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
577
507
|
// @ts-ignore
|
|
578
508
|
this.getMap().fitBounds(bounds);
|
|
579
509
|
};
|
|
@@ -687,7 +617,7 @@ var Clusterer = /** @class */ (function () {
|
|
|
687
617
|
};
|
|
688
618
|
Clusterer.prototype.addMarkers = function (markers, optNoDraw) {
|
|
689
619
|
for (var key in markers) {
|
|
690
|
-
if (
|
|
620
|
+
if (Object.prototype.hasOwnProperty.call(markers, key)) {
|
|
691
621
|
this.pushMarkerTo(markers[key]);
|
|
692
622
|
}
|
|
693
623
|
}
|
|
@@ -699,7 +629,6 @@ var Clusterer = /** @class */ (function () {
|
|
|
699
629
|
var _this = this;
|
|
700
630
|
// If the marker is draggable add a listener so we can update the clusters on the dragend:
|
|
701
631
|
if (marker.getDraggable()) {
|
|
702
|
-
// eslint-disable-next-line @getify/proper-arrows/name, @getify/proper-arrows/this
|
|
703
632
|
google.maps.event.addListener(marker, 'dragend', function () {
|
|
704
633
|
if (_this.ready) {
|
|
705
634
|
marker.isAdded = false;
|
|
@@ -766,7 +695,6 @@ var Clusterer = /** @class */ (function () {
|
|
|
766
695
|
}, 0);
|
|
767
696
|
};
|
|
768
697
|
Clusterer.prototype.getExtendedBounds = function (bounds) {
|
|
769
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
770
698
|
// @ts-ignore
|
|
771
699
|
var projection = this.getProjection();
|
|
772
700
|
// Convert the points to pixels and the extend out by the grid size.
|
|
@@ -877,16 +805,13 @@ var Clusterer = /** @class */ (function () {
|
|
|
877
805
|
//
|
|
878
806
|
// See Comments 9 & 11 on Issue 3651 relating to this workaround for a Google Maps bug:
|
|
879
807
|
var mapBounds =
|
|
880
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
881
808
|
// @ts-ignore
|
|
882
809
|
this.getMap().getZoom() > 3
|
|
883
810
|
? new google.maps.LatLngBounds(
|
|
884
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
885
811
|
// @ts-ignore
|
|
886
812
|
this.getMap()
|
|
887
813
|
.getBounds()
|
|
888
814
|
.getSouthWest(),
|
|
889
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
890
815
|
// @ts-ignore
|
|
891
816
|
this.getMap()
|
|
892
817
|
.getBounds()
|
|
@@ -903,9 +828,7 @@ var Clusterer = /** @class */ (function () {
|
|
|
903
828
|
}
|
|
904
829
|
}
|
|
905
830
|
if (iLast < this.markers.length) {
|
|
906
|
-
this.timerRefStatic = window.setTimeout(
|
|
907
|
-
// eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
|
|
908
|
-
function () {
|
|
831
|
+
this.timerRefStatic = window.setTimeout(function () {
|
|
909
832
|
_this.createClusters(iLast);
|
|
910
833
|
}, 0);
|
|
911
834
|
}
|
|
@@ -928,11 +851,9 @@ var Clusterer = /** @class */ (function () {
|
|
|
928
851
|
return function applyExtend(object) {
|
|
929
852
|
// eslint-disable-next-line guard-for-in
|
|
930
853
|
for (var property in object.prototype) {
|
|
931
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
932
854
|
// @ts-ignore
|
|
933
855
|
this.prototype[property] = object.prototype[property];
|
|
934
856
|
}
|
|
935
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
936
857
|
// @ts-ignore
|
|
937
858
|
return this;
|
|
938
859
|
}.apply(obj1, [obj2]);
|