@react-google-maps/marker-clusterer 2.16.1 → 2.19.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/Cluster.d.ts +28 -0
- package/dist/ClusterIcon.d.ts +43 -0
- package/dist/Clusterer.d.ts +86 -0
- package/dist/__tests__/clusterer.test.d.ts +4 -0
- package/dist/cjs.js +70 -50
- 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 +70 -50
- 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 +31 -31
- package/dist/types.d.ts +44 -0
- package/dist/umd.js +70 -50
- 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 +9 -8
- package/src/Cluster.tsx +7 -7
- package/src/ClusterIcon.tsx +23 -20
- package/src/Clusterer.tsx +32 -28
- package/src/types.tsx +29 -29
package/dist/umd.js
CHANGED
|
@@ -166,15 +166,15 @@
|
|
|
166
166
|
this.visible = false;
|
|
167
167
|
};
|
|
168
168
|
ClusterIcon.prototype.show = function () {
|
|
169
|
-
var _a, _b, _c, _d;
|
|
169
|
+
var _a, _b, _c, _d, _e, _f;
|
|
170
170
|
if (this.div && this.center) {
|
|
171
171
|
var divTitle = this.sums === null ||
|
|
172
172
|
typeof this.sums.title === 'undefined' ||
|
|
173
173
|
this.sums.title === '' ? this.cluster.getClusterer().getTitle() : this.sums.title;
|
|
174
174
|
// NOTE: values must be specified in px units
|
|
175
175
|
var bp = this.backgroundPosition.split(' ');
|
|
176
|
-
var spriteH = parseInt(bp[0].replace(/^\s+|\s+$/g, ''), 10);
|
|
177
|
-
var spriteV = parseInt(bp[1].replace(/^\s+|\s+$/g, ''), 10);
|
|
176
|
+
var spriteH = parseInt(((_a = bp[0]) === null || _a === void 0 ? void 0 : _a.replace(/^\s+|\s+$/g, '')) || '0', 10);
|
|
177
|
+
var spriteV = parseInt(((_b = bp[1]) === null || _b === void 0 ? void 0 : _b.replace(/^\s+|\s+$/g, '')) || '0', 10);
|
|
178
178
|
var pos = this.getPosFromLatLng(this.center);
|
|
179
179
|
this.div.className = this.className;
|
|
180
180
|
this.div.setAttribute('style', "cursor: pointer; position: absolute; top: ".concat(pos !== null ? "".concat(pos.y, "px") : '0', "; left: ").concat(pos !== null ? "".concat(pos.x, "px") : '0', "; width: ").concat(this.width, "px; height: ").concat(this.height, "px; "));
|
|
@@ -189,10 +189,10 @@
|
|
|
189
189
|
}
|
|
190
190
|
var textElm = document.createElement('div');
|
|
191
191
|
textElm.setAttribute('style', "position: absolute; top: ".concat(this.anchorText[0], "px; left: ").concat(this.anchorText[1], "px; color: ").concat(this.textColor, "; font-size: ").concat(this.textSize, "px; font-family: ").concat(this.fontFamily, "; font-weight: ").concat(this.fontWeight, "; fontStyle: ").concat(this.fontStyle, "; text-decoration: ").concat(this.textDecoration, "; text-align: center; width: ").concat(this.width, "px; line-height: ").concat(this.height, "px"));
|
|
192
|
-
if ((
|
|
193
|
-
textElm.innerText = "".concat((
|
|
194
|
-
if ((
|
|
195
|
-
textElm.innerHTML = "".concat((
|
|
192
|
+
if ((_c = this.sums) === null || _c === void 0 ? void 0 : _c.text)
|
|
193
|
+
textElm.innerText = "".concat((_d = this.sums) === null || _d === void 0 ? void 0 : _d.text);
|
|
194
|
+
if ((_e = this.sums) === null || _e === void 0 ? void 0 : _e.html)
|
|
195
|
+
textElm.innerHTML = "".concat((_f = this.sums) === null || _f === void 0 ? void 0 : _f.html);
|
|
196
196
|
this.div.innerHTML = '';
|
|
197
197
|
this.div.appendChild(img);
|
|
198
198
|
this.div.appendChild(textElm);
|
|
@@ -205,20 +205,23 @@
|
|
|
205
205
|
this.sums = sums;
|
|
206
206
|
var styles = this.cluster.getClusterer().getStyles();
|
|
207
207
|
var style = styles[Math.min(styles.length - 1, Math.max(0, sums.index - 1))];
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
208
|
+
if (style) {
|
|
209
|
+
this.url = style.url;
|
|
210
|
+
this.height = style.height;
|
|
211
|
+
this.width = style.width;
|
|
212
|
+
if (style.className) {
|
|
213
|
+
this.className = "".concat(this.clusterClassName, " ").concat(style.className);
|
|
214
|
+
}
|
|
215
|
+
this.anchorText = style.anchorText || [0, 0];
|
|
216
|
+
this.anchorIcon = style.anchorIcon || [this.height / 2, this.width / 2];
|
|
217
|
+
this.textColor = style.textColor || 'black';
|
|
218
|
+
this.textSize = style.textSize || 11;
|
|
219
|
+
this.textDecoration = style.textDecoration || 'none';
|
|
220
|
+
this.fontWeight = style.fontWeight || 'bold';
|
|
221
|
+
this.fontStyle = style.fontStyle || 'normal';
|
|
222
|
+
this.fontFamily = style.fontFamily || 'Arial,sans-serif';
|
|
223
|
+
this.backgroundPosition = style.backgroundPosition || '0 0';
|
|
224
|
+
}
|
|
222
225
|
};
|
|
223
226
|
ClusterIcon.prototype.setCenter = function (center) {
|
|
224
227
|
this.center = center;
|
|
@@ -234,6 +237,7 @@
|
|
|
234
237
|
return ClusterIcon;
|
|
235
238
|
}());
|
|
236
239
|
|
|
240
|
+
/* global google */
|
|
237
241
|
var Cluster = /** @class */ (function () {
|
|
238
242
|
function Cluster(markerClusterer) {
|
|
239
243
|
this.markerClusterer = markerClusterer;
|
|
@@ -276,8 +280,9 @@
|
|
|
276
280
|
Cluster.prototype.getBounds = function () {
|
|
277
281
|
var bounds = new google.maps.LatLngBounds(this.center, this.center);
|
|
278
282
|
var markers = this.getMarkers();
|
|
279
|
-
for (var
|
|
280
|
-
var
|
|
283
|
+
for (var _i = 0, markers_1 = markers; _i < markers_1.length; _i++) {
|
|
284
|
+
var marker = markers_1[_i];
|
|
285
|
+
var position = marker.getPosition();
|
|
281
286
|
if (position) {
|
|
282
287
|
bounds.extend(position);
|
|
283
288
|
}
|
|
@@ -332,8 +337,9 @@
|
|
|
332
337
|
}
|
|
333
338
|
else if (mCount === this.minClusterSize) {
|
|
334
339
|
// Hide the markers that were showing.
|
|
335
|
-
for (var
|
|
336
|
-
|
|
340
|
+
for (var _i = 0, _b = this.markers; _i < _b.length; _i++) {
|
|
341
|
+
var markerElement = _b[_i];
|
|
342
|
+
markerElement.setMap(null);
|
|
337
343
|
}
|
|
338
344
|
}
|
|
339
345
|
else {
|
|
@@ -540,19 +546,22 @@
|
|
|
540
546
|
};
|
|
541
547
|
Clusterer.prototype.onRemove = function () {
|
|
542
548
|
// Put all the managed markers back on the map:
|
|
543
|
-
for (var
|
|
544
|
-
|
|
545
|
-
|
|
549
|
+
for (var _i = 0, _a = this.markers; _i < _a.length; _i++) {
|
|
550
|
+
var marker = _a[_i];
|
|
551
|
+
if (marker.getMap() !== this.activeMap) {
|
|
552
|
+
marker.setMap(this.activeMap);
|
|
546
553
|
}
|
|
547
554
|
}
|
|
548
555
|
// Remove all clusters:
|
|
549
|
-
for (var
|
|
550
|
-
|
|
556
|
+
for (var _b = 0, _c = this.clusters; _b < _c.length; _b++) {
|
|
557
|
+
var cluster = _c[_b];
|
|
558
|
+
cluster.remove();
|
|
551
559
|
}
|
|
552
560
|
this.clusters = [];
|
|
553
561
|
// Remove map event listeners:
|
|
554
|
-
for (var
|
|
555
|
-
|
|
562
|
+
for (var _d = 0, _e = this.listeners; _d < _e.length; _d++) {
|
|
563
|
+
var listener = _e[_d];
|
|
564
|
+
google.maps.event.removeListener(listener);
|
|
556
565
|
}
|
|
557
566
|
this.listeners = [];
|
|
558
567
|
this.activeMap = null;
|
|
@@ -566,16 +575,17 @@
|
|
|
566
575
|
for (var i = 0; i < this.imageSizes.length; i++) {
|
|
567
576
|
this.styles.push({
|
|
568
577
|
url: "".concat(this.imagePath + (i + 1), ".").concat(this.imageExtension),
|
|
569
|
-
height: this.imageSizes[i],
|
|
570
|
-
width: this.imageSizes[i],
|
|
578
|
+
height: this.imageSizes[i] || 0,
|
|
579
|
+
width: this.imageSizes[i] || 0,
|
|
571
580
|
});
|
|
572
581
|
}
|
|
573
582
|
};
|
|
574
583
|
Clusterer.prototype.fitMapToMarkers = function () {
|
|
575
584
|
var markers = this.getMarkers();
|
|
576
585
|
var bounds = new google.maps.LatLngBounds();
|
|
577
|
-
for (var
|
|
578
|
-
var
|
|
586
|
+
for (var _i = 0, markers_1 = markers; _i < markers_1.length; _i++) {
|
|
587
|
+
var marker = markers_1[_i];
|
|
588
|
+
var position = marker.getPosition();
|
|
579
589
|
if (position) {
|
|
580
590
|
bounds.extend(position);
|
|
581
591
|
}
|
|
@@ -696,7 +706,10 @@
|
|
|
696
706
|
Clusterer.prototype.addMarkers = function (markers, optNoDraw) {
|
|
697
707
|
for (var key in markers) {
|
|
698
708
|
if (Object.prototype.hasOwnProperty.call(markers, key)) {
|
|
699
|
-
|
|
709
|
+
var marker = markers[key];
|
|
710
|
+
if (marker) {
|
|
711
|
+
this.pushMarkerTo(marker);
|
|
712
|
+
}
|
|
700
713
|
}
|
|
701
714
|
}
|
|
702
715
|
if (!optNoDraw) {
|
|
@@ -747,8 +760,9 @@
|
|
|
747
760
|
};
|
|
748
761
|
Clusterer.prototype.removeMarkers = function (markers, optNoDraw) {
|
|
749
762
|
var removed = false;
|
|
750
|
-
for (var
|
|
751
|
-
|
|
763
|
+
for (var _i = 0, markers_2 = markers; _i < markers_2.length; _i++) {
|
|
764
|
+
var marker = markers_2[_i];
|
|
765
|
+
removed = removed || this.removeMarker_(marker);
|
|
752
766
|
}
|
|
753
767
|
if (!optNoDraw && removed) {
|
|
754
768
|
this.repaint();
|
|
@@ -767,8 +781,9 @@
|
|
|
767
781
|
// Remove the old clusters.
|
|
768
782
|
// Do it in a timeout to prevent blinking effect.
|
|
769
783
|
setTimeout(function timeout() {
|
|
770
|
-
for (var
|
|
771
|
-
|
|
784
|
+
for (var _i = 0, oldClusters_1 = oldClusters; _i < oldClusters_1.length; _i++) {
|
|
785
|
+
var oldCluster = oldClusters_1[_i];
|
|
786
|
+
oldCluster.remove();
|
|
772
787
|
}
|
|
773
788
|
}, 0);
|
|
774
789
|
};
|
|
@@ -812,13 +827,14 @@
|
|
|
812
827
|
};
|
|
813
828
|
Clusterer.prototype.resetViewport = function (optHide) {
|
|
814
829
|
// Remove all the clusters
|
|
815
|
-
for (var
|
|
816
|
-
|
|
830
|
+
for (var _i = 0, _a = this.clusters; _i < _a.length; _i++) {
|
|
831
|
+
var cluster = _a[_i];
|
|
832
|
+
cluster.remove();
|
|
817
833
|
}
|
|
818
834
|
this.clusters = [];
|
|
819
835
|
// Reset the markers to not be added and to be removed from the map.
|
|
820
|
-
for (var
|
|
821
|
-
var marker =
|
|
836
|
+
for (var _b = 0, _c = this.markers; _b < _c.length; _b++) {
|
|
837
|
+
var marker = _c[_b];
|
|
822
838
|
marker.isAdded = false;
|
|
823
839
|
if (optHide) {
|
|
824
840
|
marker.setMap(null);
|
|
@@ -847,8 +863,9 @@
|
|
|
847
863
|
var cluster;
|
|
848
864
|
var distance = 40000; // Some large number
|
|
849
865
|
var clusterToAddTo = null;
|
|
850
|
-
for (var
|
|
851
|
-
|
|
866
|
+
for (var _i = 0, _a = this.clusters; _i < _a.length; _i++) {
|
|
867
|
+
var clusterElement = _a[_i];
|
|
868
|
+
cluster = clusterElement;
|
|
852
869
|
var center = cluster.getCenter();
|
|
853
870
|
var position = marker.getPosition();
|
|
854
871
|
if (center && position) {
|
|
@@ -904,7 +921,7 @@
|
|
|
904
921
|
var iLast = Math.min(iFirst + this.batchSize, this.markers.length);
|
|
905
922
|
for (var i = iFirst; i < iLast; i++) {
|
|
906
923
|
var marker = this.markers[i];
|
|
907
|
-
if (!marker.isAdded && this.isMarkerInBounds(marker, extendedMapBounds) && (!this.ignoreHidden || (this.ignoreHidden && marker.getVisible()))) {
|
|
924
|
+
if (marker && !marker.isAdded && this.isMarkerInBounds(marker, extendedMapBounds) && (!this.ignoreHidden || (this.ignoreHidden && marker.getVisible()))) {
|
|
908
925
|
this.addToClosestCluster(marker);
|
|
909
926
|
}
|
|
910
927
|
}
|
|
@@ -923,18 +940,21 @@
|
|
|
923
940
|
* @event
|
|
924
941
|
*/
|
|
925
942
|
google.maps.event.trigger(this, 'clusteringend', this);
|
|
926
|
-
for (var
|
|
927
|
-
|
|
943
|
+
for (var _i = 0, _a = this.clusters; _i < _a.length; _i++) {
|
|
944
|
+
var cluster = _a[_i];
|
|
945
|
+
cluster.updateIcon();
|
|
928
946
|
}
|
|
929
947
|
}
|
|
930
948
|
};
|
|
931
949
|
Clusterer.prototype.extend = function (obj1, obj2) {
|
|
932
950
|
return function applyExtend(object) {
|
|
933
951
|
for (var property in object.prototype) {
|
|
952
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
934
953
|
// @ts-ignore
|
|
935
954
|
this.prototype[property] = object.prototype[property];
|
|
936
955
|
}
|
|
937
956
|
return this;
|
|
957
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
938
958
|
}.apply(obj1, [obj2]);
|
|
939
959
|
};
|
|
940
960
|
return Clusterer;
|