@react-google-maps/marker-clusterer 2.16.1 → 2.19.1
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 +107 -0
- package/dist/__tests__/clusterer.test.d.ts +4 -0
- package/dist/cjs.js +98 -52
- 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 -52
- 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 +54 -33
- package/dist/types.d.ts +44 -0
- package/dist/umd.js +98 -52
- 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 +81 -40
- package/src/types.tsx +29 -29
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="google.maps" />
|
|
2
|
+
import type { Clusterer } from './Clusterer';
|
|
3
|
+
import { ClusterIcon } from './ClusterIcon';
|
|
4
|
+
import type { MarkerExtended } from './types';
|
|
5
|
+
export declare class Cluster {
|
|
6
|
+
markerClusterer: Clusterer;
|
|
7
|
+
map: google.maps.Map | google.maps.StreetViewPanorama | null;
|
|
8
|
+
gridSize: number;
|
|
9
|
+
minClusterSize: number;
|
|
10
|
+
averageCenter: boolean;
|
|
11
|
+
markers: MarkerExtended[];
|
|
12
|
+
center: google.maps.LatLng | undefined;
|
|
13
|
+
bounds: google.maps.LatLngBounds | null;
|
|
14
|
+
clusterIcon: ClusterIcon;
|
|
15
|
+
constructor(markerClusterer: Clusterer);
|
|
16
|
+
getSize(): number;
|
|
17
|
+
getMarkers(): MarkerExtended[];
|
|
18
|
+
getCenter(): google.maps.LatLng | undefined;
|
|
19
|
+
getMap(): google.maps.Map | google.maps.StreetViewPanorama | null;
|
|
20
|
+
getClusterer(): Clusterer;
|
|
21
|
+
getBounds(): google.maps.LatLngBounds;
|
|
22
|
+
remove(): void;
|
|
23
|
+
addMarker(marker: MarkerExtended): boolean;
|
|
24
|
+
isMarkerInClusterBounds(marker: MarkerExtended): boolean;
|
|
25
|
+
calculateBounds(): void;
|
|
26
|
+
updateIcon(): void;
|
|
27
|
+
isMarkerAlreadyAdded(marker: MarkerExtended): boolean;
|
|
28
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/// <reference types="google.maps" />
|
|
2
|
+
import type { Cluster } from './Cluster';
|
|
3
|
+
import type { ClusterIconStyle, ClusterIconInfo } from './types';
|
|
4
|
+
export declare class ClusterIcon {
|
|
5
|
+
cluster: Cluster;
|
|
6
|
+
className: string;
|
|
7
|
+
clusterClassName: string;
|
|
8
|
+
styles: ClusterIconStyle[];
|
|
9
|
+
center: google.maps.LatLng | undefined;
|
|
10
|
+
div: HTMLDivElement | null;
|
|
11
|
+
sums: ClusterIconInfo | null;
|
|
12
|
+
visible: boolean;
|
|
13
|
+
url: string;
|
|
14
|
+
height: number;
|
|
15
|
+
width: number;
|
|
16
|
+
anchorText: [number, number];
|
|
17
|
+
anchorIcon: [number, number];
|
|
18
|
+
textColor: string;
|
|
19
|
+
textSize: number;
|
|
20
|
+
textDecoration: string;
|
|
21
|
+
fontWeight: string;
|
|
22
|
+
fontStyle: string;
|
|
23
|
+
fontFamily: string;
|
|
24
|
+
backgroundPosition: string;
|
|
25
|
+
cMouseDownInCluster: boolean | null;
|
|
26
|
+
cDraggingMapByCluster: boolean | null;
|
|
27
|
+
timeOut: number | null;
|
|
28
|
+
boundsChangedListener: google.maps.MapsEventListener | null;
|
|
29
|
+
constructor(cluster: Cluster, styles: ClusterIconStyle[]);
|
|
30
|
+
onBoundsChanged(): void;
|
|
31
|
+
onMouseDown(): void;
|
|
32
|
+
onClick(event: Event): void;
|
|
33
|
+
onMouseOver(): void;
|
|
34
|
+
onMouseOut(): void;
|
|
35
|
+
onAdd(): void;
|
|
36
|
+
onRemove(): void;
|
|
37
|
+
draw(): void;
|
|
38
|
+
hide(): void;
|
|
39
|
+
show(): void;
|
|
40
|
+
useStyle(sums: ClusterIconInfo): void;
|
|
41
|
+
setCenter(center: google.maps.LatLng): void;
|
|
42
|
+
getPosFromLatLng(latlng: google.maps.LatLng): google.maps.Point | null;
|
|
43
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/// <reference types="google.maps" />
|
|
2
|
+
import { Cluster } from './Cluster';
|
|
3
|
+
import type { ClusterIcon } from './ClusterIcon';
|
|
4
|
+
import type { MarkerExtended, ClustererOptions, ClusterIconStyle, TCalculator } from './types';
|
|
5
|
+
export declare class Clusterer implements google.maps.OverlayView {
|
|
6
|
+
markers: MarkerExtended[];
|
|
7
|
+
clusters: Cluster[];
|
|
8
|
+
listeners: google.maps.MapsEventListener[];
|
|
9
|
+
activeMap: google.maps.Map | google.maps.StreetViewPanorama | null;
|
|
10
|
+
ready: boolean;
|
|
11
|
+
gridSize: number;
|
|
12
|
+
minClusterSize: number;
|
|
13
|
+
maxZoom: number | null;
|
|
14
|
+
styles: ClusterIconStyle[];
|
|
15
|
+
title: string;
|
|
16
|
+
zoomOnClick: boolean;
|
|
17
|
+
averageCenter: boolean;
|
|
18
|
+
ignoreHidden: boolean;
|
|
19
|
+
enableRetinaIcons: boolean;
|
|
20
|
+
imagePath: string;
|
|
21
|
+
imageExtension: string;
|
|
22
|
+
imageSizes: number[];
|
|
23
|
+
calculator: TCalculator;
|
|
24
|
+
batchSize: number;
|
|
25
|
+
batchSizeIE: number;
|
|
26
|
+
clusterClass: string;
|
|
27
|
+
timerRefStatic: number | null;
|
|
28
|
+
constructor(map: google.maps.Map, optMarkers?: MarkerExtended[], optOptions?: ClustererOptions);
|
|
29
|
+
onZoomChanged(): void;
|
|
30
|
+
onIdle(): void;
|
|
31
|
+
onAdd(): void;
|
|
32
|
+
onRemove(): void;
|
|
33
|
+
draw(): void;
|
|
34
|
+
getMap(): null;
|
|
35
|
+
getPanes(): null;
|
|
36
|
+
getProjection(): {
|
|
37
|
+
fromContainerPixelToLatLng(): null;
|
|
38
|
+
fromDivPixelToLatLng(): null;
|
|
39
|
+
fromLatLngToContainerPixel(): null;
|
|
40
|
+
fromLatLngToDivPixel(): null;
|
|
41
|
+
getVisibleRegion(): null;
|
|
42
|
+
getWorldWidth(): number;
|
|
43
|
+
};
|
|
44
|
+
setMap(): void;
|
|
45
|
+
addListener(): {
|
|
46
|
+
remove(): void;
|
|
47
|
+
};
|
|
48
|
+
bindTo(): void;
|
|
49
|
+
get(): void;
|
|
50
|
+
notify(): void;
|
|
51
|
+
set(): void;
|
|
52
|
+
setValues(): void;
|
|
53
|
+
unbind(): void;
|
|
54
|
+
unbindAll(): void;
|
|
55
|
+
setupStyles(): void;
|
|
56
|
+
fitMapToMarkers(): void;
|
|
57
|
+
getGridSize(): number;
|
|
58
|
+
setGridSize(gridSize: number): void;
|
|
59
|
+
getMinimumClusterSize(): number;
|
|
60
|
+
setMinimumClusterSize(minimumClusterSize: number): void;
|
|
61
|
+
getMaxZoom(): number | null;
|
|
62
|
+
setMaxZoom(maxZoom: number): void;
|
|
63
|
+
getStyles(): ClusterIconStyle[];
|
|
64
|
+
setStyles(styles: ClusterIconStyle[]): void;
|
|
65
|
+
getTitle(): string;
|
|
66
|
+
setTitle(title: string): void;
|
|
67
|
+
getZoomOnClick(): boolean;
|
|
68
|
+
setZoomOnClick(zoomOnClick: boolean): void;
|
|
69
|
+
getAverageCenter(): boolean;
|
|
70
|
+
setAverageCenter(averageCenter: boolean): void;
|
|
71
|
+
getIgnoreHidden(): boolean;
|
|
72
|
+
setIgnoreHidden(ignoreHidden: boolean): void;
|
|
73
|
+
getEnableRetinaIcons(): boolean;
|
|
74
|
+
setEnableRetinaIcons(enableRetinaIcons: boolean): void;
|
|
75
|
+
getImageExtension(): string;
|
|
76
|
+
setImageExtension(imageExtension: string): void;
|
|
77
|
+
getImagePath(): string;
|
|
78
|
+
setImagePath(imagePath: string): void;
|
|
79
|
+
getImageSizes(): number[];
|
|
80
|
+
setImageSizes(imageSizes: number[]): void;
|
|
81
|
+
getCalculator(): TCalculator;
|
|
82
|
+
setCalculator(calculator: TCalculator): void;
|
|
83
|
+
getBatchSizeIE(): number;
|
|
84
|
+
setBatchSizeIE(batchSizeIE: number): void;
|
|
85
|
+
getClusterClass(): string;
|
|
86
|
+
setClusterClass(clusterClass: string): void;
|
|
87
|
+
getMarkers(): MarkerExtended[];
|
|
88
|
+
getTotalMarkers(): number;
|
|
89
|
+
getClusters(): Cluster[];
|
|
90
|
+
getTotalClusters(): number;
|
|
91
|
+
addMarker(marker: MarkerExtended, optNoDraw: boolean): void;
|
|
92
|
+
addMarkers(markers: MarkerExtended[], optNoDraw: boolean): void;
|
|
93
|
+
pushMarkerTo(marker: MarkerExtended): void;
|
|
94
|
+
removeMarker_(marker: MarkerExtended): boolean;
|
|
95
|
+
removeMarker(marker: MarkerExtended, optNoDraw: boolean): boolean;
|
|
96
|
+
removeMarkers(markers: MarkerExtended[], optNoDraw: boolean): boolean;
|
|
97
|
+
clearMarkers(): void;
|
|
98
|
+
repaint(): void;
|
|
99
|
+
getExtendedBounds(bounds: google.maps.LatLngBounds): google.maps.LatLngBounds;
|
|
100
|
+
redraw(): void;
|
|
101
|
+
resetViewport(optHide: boolean): void;
|
|
102
|
+
distanceBetweenPoints(p1: google.maps.LatLng, p2: google.maps.LatLng): number;
|
|
103
|
+
isMarkerInBounds(marker: MarkerExtended, bounds: google.maps.LatLngBounds): boolean;
|
|
104
|
+
addToClosestCluster(marker: MarkerExtended): void;
|
|
105
|
+
createClusters(iFirst: number): void;
|
|
106
|
+
extend<A extends typeof Clusterer | typeof ClusterIcon>(obj1: A, obj2: typeof google.maps.OverlayView): A;
|
|
107
|
+
}
|
package/dist/cjs.js
CHANGED
|
@@ -164,15 +164,15 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
164
164
|
this.visible = false;
|
|
165
165
|
};
|
|
166
166
|
ClusterIcon.prototype.show = function () {
|
|
167
|
-
var _a, _b, _c, _d;
|
|
167
|
+
var _a, _b, _c, _d, _e, _f;
|
|
168
168
|
if (this.div && this.center) {
|
|
169
169
|
var divTitle = this.sums === null ||
|
|
170
170
|
typeof this.sums.title === 'undefined' ||
|
|
171
171
|
this.sums.title === '' ? this.cluster.getClusterer().getTitle() : this.sums.title;
|
|
172
172
|
// NOTE: values must be specified in px units
|
|
173
173
|
var bp = this.backgroundPosition.split(' ');
|
|
174
|
-
var spriteH = parseInt(bp[0].replace(/^\s+|\s+$/g, ''), 10);
|
|
175
|
-
var spriteV = parseInt(bp[1].replace(/^\s+|\s+$/g, ''), 10);
|
|
174
|
+
var spriteH = parseInt(((_a = bp[0]) === null || _a === void 0 ? void 0 : _a.replace(/^\s+|\s+$/g, '')) || '0', 10);
|
|
175
|
+
var spriteV = parseInt(((_b = bp[1]) === null || _b === void 0 ? void 0 : _b.replace(/^\s+|\s+$/g, '')) || '0', 10);
|
|
176
176
|
var pos = this.getPosFromLatLng(this.center);
|
|
177
177
|
this.div.className = this.className;
|
|
178
178
|
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; "));
|
|
@@ -187,10 +187,10 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
187
187
|
}
|
|
188
188
|
var textElm = document.createElement('div');
|
|
189
189
|
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"));
|
|
190
|
-
if ((
|
|
191
|
-
textElm.innerText = "".concat((
|
|
192
|
-
if ((
|
|
193
|
-
textElm.innerHTML = "".concat((
|
|
190
|
+
if ((_c = this.sums) === null || _c === void 0 ? void 0 : _c.text)
|
|
191
|
+
textElm.innerText = "".concat((_d = this.sums) === null || _d === void 0 ? void 0 : _d.text);
|
|
192
|
+
if ((_e = this.sums) === null || _e === void 0 ? void 0 : _e.html)
|
|
193
|
+
textElm.innerHTML = "".concat((_f = this.sums) === null || _f === void 0 ? void 0 : _f.html);
|
|
194
194
|
this.div.innerHTML = '';
|
|
195
195
|
this.div.appendChild(img);
|
|
196
196
|
this.div.appendChild(textElm);
|
|
@@ -203,20 +203,23 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
203
203
|
this.sums = sums;
|
|
204
204
|
var styles = this.cluster.getClusterer().getStyles();
|
|
205
205
|
var style = styles[Math.min(styles.length - 1, Math.max(0, sums.index - 1))];
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
206
|
+
if (style) {
|
|
207
|
+
this.url = style.url;
|
|
208
|
+
this.height = style.height;
|
|
209
|
+
this.width = style.width;
|
|
210
|
+
if (style.className) {
|
|
211
|
+
this.className = "".concat(this.clusterClassName, " ").concat(style.className);
|
|
212
|
+
}
|
|
213
|
+
this.anchorText = style.anchorText || [0, 0];
|
|
214
|
+
this.anchorIcon = style.anchorIcon || [this.height / 2, this.width / 2];
|
|
215
|
+
this.textColor = style.textColor || 'black';
|
|
216
|
+
this.textSize = style.textSize || 11;
|
|
217
|
+
this.textDecoration = style.textDecoration || 'none';
|
|
218
|
+
this.fontWeight = style.fontWeight || 'bold';
|
|
219
|
+
this.fontStyle = style.fontStyle || 'normal';
|
|
220
|
+
this.fontFamily = style.fontFamily || 'Arial,sans-serif';
|
|
221
|
+
this.backgroundPosition = style.backgroundPosition || '0 0';
|
|
222
|
+
}
|
|
220
223
|
};
|
|
221
224
|
ClusterIcon.prototype.setCenter = function (center) {
|
|
222
225
|
this.center = center;
|
|
@@ -232,6 +235,7 @@ var ClusterIcon = /** @class */ (function () {
|
|
|
232
235
|
return ClusterIcon;
|
|
233
236
|
}());
|
|
234
237
|
|
|
238
|
+
/* global google */
|
|
235
239
|
var Cluster = /** @class */ (function () {
|
|
236
240
|
function Cluster(markerClusterer) {
|
|
237
241
|
this.markerClusterer = markerClusterer;
|
|
@@ -274,8 +278,9 @@ var Cluster = /** @class */ (function () {
|
|
|
274
278
|
Cluster.prototype.getBounds = function () {
|
|
275
279
|
var bounds = new google.maps.LatLngBounds(this.center, this.center);
|
|
276
280
|
var markers = this.getMarkers();
|
|
277
|
-
for (var
|
|
278
|
-
var
|
|
281
|
+
for (var _i = 0, markers_1 = markers; _i < markers_1.length; _i++) {
|
|
282
|
+
var marker = markers_1[_i];
|
|
283
|
+
var position = marker.getPosition();
|
|
279
284
|
if (position) {
|
|
280
285
|
bounds.extend(position);
|
|
281
286
|
}
|
|
@@ -330,8 +335,9 @@ var Cluster = /** @class */ (function () {
|
|
|
330
335
|
}
|
|
331
336
|
else if (mCount === this.minClusterSize) {
|
|
332
337
|
// Hide the markers that were showing.
|
|
333
|
-
for (var
|
|
334
|
-
|
|
338
|
+
for (var _i = 0, _b = this.markers; _i < _b.length; _i++) {
|
|
339
|
+
var markerElement = _b[_i];
|
|
340
|
+
markerElement.setMap(null);
|
|
335
341
|
}
|
|
336
342
|
}
|
|
337
343
|
else {
|
|
@@ -461,9 +467,9 @@ var Clusterer = /** @class */ (function () {
|
|
|
461
467
|
this.repaint = this.repaint.bind(this);
|
|
462
468
|
this.onIdle = this.onIdle.bind(this);
|
|
463
469
|
this.redraw = this.redraw.bind(this);
|
|
464
|
-
this.extend = this.extend.bind(this);
|
|
465
470
|
this.onAdd = this.onAdd.bind(this);
|
|
466
471
|
this.draw = this.draw.bind(this);
|
|
472
|
+
this.extend = this.extend.bind(this);
|
|
467
473
|
this.extend(Clusterer, google.maps.OverlayView);
|
|
468
474
|
this.markers = [];
|
|
469
475
|
this.clusters = [];
|
|
@@ -538,25 +544,53 @@ var Clusterer = /** @class */ (function () {
|
|
|
538
544
|
};
|
|
539
545
|
Clusterer.prototype.onRemove = function () {
|
|
540
546
|
// Put all the managed markers back on the map:
|
|
541
|
-
for (var
|
|
542
|
-
|
|
543
|
-
|
|
547
|
+
for (var _i = 0, _a = this.markers; _i < _a.length; _i++) {
|
|
548
|
+
var marker = _a[_i];
|
|
549
|
+
if (marker.getMap() !== this.activeMap) {
|
|
550
|
+
marker.setMap(this.activeMap);
|
|
544
551
|
}
|
|
545
552
|
}
|
|
546
553
|
// Remove all clusters:
|
|
547
|
-
for (var
|
|
548
|
-
|
|
554
|
+
for (var _b = 0, _c = this.clusters; _b < _c.length; _b++) {
|
|
555
|
+
var cluster = _c[_b];
|
|
556
|
+
cluster.remove();
|
|
549
557
|
}
|
|
550
558
|
this.clusters = [];
|
|
551
559
|
// Remove map event listeners:
|
|
552
|
-
for (var
|
|
553
|
-
|
|
560
|
+
for (var _d = 0, _e = this.listeners; _d < _e.length; _d++) {
|
|
561
|
+
var listener = _e[_d];
|
|
562
|
+
google.maps.event.removeListener(listener);
|
|
554
563
|
}
|
|
555
564
|
this.listeners = [];
|
|
556
565
|
this.activeMap = null;
|
|
557
566
|
this.ready = false;
|
|
558
567
|
};
|
|
559
568
|
Clusterer.prototype.draw = function () { return; };
|
|
569
|
+
Clusterer.prototype.getMap = function () { return null; };
|
|
570
|
+
Clusterer.prototype.getPanes = function () { return null; };
|
|
571
|
+
Clusterer.prototype.getProjection = function () {
|
|
572
|
+
return {
|
|
573
|
+
fromContainerPixelToLatLng: function () { return null; },
|
|
574
|
+
fromDivPixelToLatLng: function () { return null; },
|
|
575
|
+
fromLatLngToContainerPixel: function () { return null; },
|
|
576
|
+
fromLatLngToDivPixel: function () { return null; },
|
|
577
|
+
getVisibleRegion: function () { return null; },
|
|
578
|
+
getWorldWidth: function () { return 0; }
|
|
579
|
+
};
|
|
580
|
+
};
|
|
581
|
+
Clusterer.prototype.setMap = function () { return; };
|
|
582
|
+
Clusterer.prototype.addListener = function () {
|
|
583
|
+
return {
|
|
584
|
+
remove: function () { return; }
|
|
585
|
+
};
|
|
586
|
+
};
|
|
587
|
+
Clusterer.prototype.bindTo = function () { return; };
|
|
588
|
+
Clusterer.prototype.get = function () { return; };
|
|
589
|
+
Clusterer.prototype.notify = function () { return; };
|
|
590
|
+
Clusterer.prototype.set = function () { return; };
|
|
591
|
+
Clusterer.prototype.setValues = function () { return; };
|
|
592
|
+
Clusterer.prototype.unbind = function () { return; };
|
|
593
|
+
Clusterer.prototype.unbindAll = function () { return; };
|
|
560
594
|
Clusterer.prototype.setupStyles = function () {
|
|
561
595
|
if (this.styles.length > 0) {
|
|
562
596
|
return;
|
|
@@ -564,16 +598,17 @@ var Clusterer = /** @class */ (function () {
|
|
|
564
598
|
for (var i = 0; i < this.imageSizes.length; i++) {
|
|
565
599
|
this.styles.push({
|
|
566
600
|
url: "".concat(this.imagePath + (i + 1), ".").concat(this.imageExtension),
|
|
567
|
-
height: this.imageSizes[i],
|
|
568
|
-
width: this.imageSizes[i],
|
|
601
|
+
height: this.imageSizes[i] || 0,
|
|
602
|
+
width: this.imageSizes[i] || 0,
|
|
569
603
|
});
|
|
570
604
|
}
|
|
571
605
|
};
|
|
572
606
|
Clusterer.prototype.fitMapToMarkers = function () {
|
|
573
607
|
var markers = this.getMarkers();
|
|
574
608
|
var bounds = new google.maps.LatLngBounds();
|
|
575
|
-
for (var
|
|
576
|
-
var
|
|
609
|
+
for (var _i = 0, markers_1 = markers; _i < markers_1.length; _i++) {
|
|
610
|
+
var marker = markers_1[_i];
|
|
611
|
+
var position = marker.getPosition();
|
|
577
612
|
if (position) {
|
|
578
613
|
bounds.extend(position);
|
|
579
614
|
}
|
|
@@ -694,7 +729,10 @@ var Clusterer = /** @class */ (function () {
|
|
|
694
729
|
Clusterer.prototype.addMarkers = function (markers, optNoDraw) {
|
|
695
730
|
for (var key in markers) {
|
|
696
731
|
if (Object.prototype.hasOwnProperty.call(markers, key)) {
|
|
697
|
-
|
|
732
|
+
var marker = markers[key];
|
|
733
|
+
if (marker) {
|
|
734
|
+
this.pushMarkerTo(marker);
|
|
735
|
+
}
|
|
698
736
|
}
|
|
699
737
|
}
|
|
700
738
|
if (!optNoDraw) {
|
|
@@ -745,8 +783,9 @@ var Clusterer = /** @class */ (function () {
|
|
|
745
783
|
};
|
|
746
784
|
Clusterer.prototype.removeMarkers = function (markers, optNoDraw) {
|
|
747
785
|
var removed = false;
|
|
748
|
-
for (var
|
|
749
|
-
|
|
786
|
+
for (var _i = 0, markers_2 = markers; _i < markers_2.length; _i++) {
|
|
787
|
+
var marker = markers_2[_i];
|
|
788
|
+
removed = removed || this.removeMarker_(marker);
|
|
750
789
|
}
|
|
751
790
|
if (!optNoDraw && removed) {
|
|
752
791
|
this.repaint();
|
|
@@ -765,8 +804,9 @@ var Clusterer = /** @class */ (function () {
|
|
|
765
804
|
// Remove the old clusters.
|
|
766
805
|
// Do it in a timeout to prevent blinking effect.
|
|
767
806
|
setTimeout(function timeout() {
|
|
768
|
-
for (var
|
|
769
|
-
|
|
807
|
+
for (var _i = 0, oldClusters_1 = oldClusters; _i < oldClusters_1.length; _i++) {
|
|
808
|
+
var oldCluster = oldClusters_1[_i];
|
|
809
|
+
oldCluster.remove();
|
|
770
810
|
}
|
|
771
811
|
}, 0);
|
|
772
812
|
};
|
|
@@ -810,13 +850,14 @@ var Clusterer = /** @class */ (function () {
|
|
|
810
850
|
};
|
|
811
851
|
Clusterer.prototype.resetViewport = function (optHide) {
|
|
812
852
|
// Remove all the clusters
|
|
813
|
-
for (var
|
|
814
|
-
|
|
853
|
+
for (var _i = 0, _a = this.clusters; _i < _a.length; _i++) {
|
|
854
|
+
var cluster = _a[_i];
|
|
855
|
+
cluster.remove();
|
|
815
856
|
}
|
|
816
857
|
this.clusters = [];
|
|
817
858
|
// Reset the markers to not be added and to be removed from the map.
|
|
818
|
-
for (var
|
|
819
|
-
var marker =
|
|
859
|
+
for (var _b = 0, _c = this.markers; _b < _c.length; _b++) {
|
|
860
|
+
var marker = _c[_b];
|
|
820
861
|
marker.isAdded = false;
|
|
821
862
|
if (optHide) {
|
|
822
863
|
marker.setMap(null);
|
|
@@ -845,8 +886,9 @@ var Clusterer = /** @class */ (function () {
|
|
|
845
886
|
var cluster;
|
|
846
887
|
var distance = 40000; // Some large number
|
|
847
888
|
var clusterToAddTo = null;
|
|
848
|
-
for (var
|
|
849
|
-
|
|
889
|
+
for (var _i = 0, _a = this.clusters; _i < _a.length; _i++) {
|
|
890
|
+
var clusterElement = _a[_i];
|
|
891
|
+
cluster = clusterElement;
|
|
850
892
|
var center = cluster.getCenter();
|
|
851
893
|
var position = marker.getPosition();
|
|
852
894
|
if (center && position) {
|
|
@@ -902,7 +944,7 @@ var Clusterer = /** @class */ (function () {
|
|
|
902
944
|
var iLast = Math.min(iFirst + this.batchSize, this.markers.length);
|
|
903
945
|
for (var i = iFirst; i < iLast; i++) {
|
|
904
946
|
var marker = this.markers[i];
|
|
905
|
-
if (!marker.isAdded && this.isMarkerInBounds(marker, extendedMapBounds) && (!this.ignoreHidden || (this.ignoreHidden && marker.getVisible()))) {
|
|
947
|
+
if (marker && !marker.isAdded && this.isMarkerInBounds(marker, extendedMapBounds) && (!this.ignoreHidden || (this.ignoreHidden && marker.getVisible()))) {
|
|
906
948
|
this.addToClosestCluster(marker);
|
|
907
949
|
}
|
|
908
950
|
}
|
|
@@ -921,16 +963,20 @@ var Clusterer = /** @class */ (function () {
|
|
|
921
963
|
* @event
|
|
922
964
|
*/
|
|
923
965
|
google.maps.event.trigger(this, 'clusteringend', this);
|
|
924
|
-
for (var
|
|
925
|
-
|
|
966
|
+
for (var _i = 0, _a = this.clusters; _i < _a.length; _i++) {
|
|
967
|
+
var cluster = _a[_i];
|
|
968
|
+
cluster.updateIcon();
|
|
926
969
|
}
|
|
927
970
|
}
|
|
928
971
|
};
|
|
929
972
|
Clusterer.prototype.extend = function (obj1, obj2) {
|
|
930
973
|
return function applyExtend(object) {
|
|
931
974
|
for (var property in object.prototype) {
|
|
975
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
976
|
+
var prop = property;
|
|
977
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
932
978
|
// @ts-ignore
|
|
933
|
-
this.prototype[
|
|
979
|
+
this.prototype[prop] = object.prototype[prop];
|
|
934
980
|
}
|
|
935
981
|
return this;
|
|
936
982
|
}.apply(obj1, [obj2]);
|