@react-google-maps/marker-clusterer 2.11.6 → 2.14.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.
@@ -0,0 +1,28 @@
1
+ /// <reference types="google.maps" />
2
+ import { Clusterer } from './Clusterer';
3
+ import { ClusterIcon } from './ClusterIcon';
4
+ import { 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 { Cluster } from './Cluster';
3
+ import { 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[];
17
+ anchorIcon: 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,86 @@
1
+ /// <reference types="google.maps" />
2
+ import { Cluster } from './Cluster';
3
+ import { ClusterIcon } from './ClusterIcon';
4
+ import { MarkerExtended, ClustererOptions, ClusterIconStyle, TCalculator } from './types';
5
+ export declare class Clusterer {
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
+ setupStyles(): void;
35
+ fitMapToMarkers(): void;
36
+ getGridSize(): number;
37
+ setGridSize(gridSize: number): void;
38
+ getMinimumClusterSize(): number;
39
+ setMinimumClusterSize(minimumClusterSize: number): void;
40
+ getMaxZoom(): number | null;
41
+ setMaxZoom(maxZoom: number): void;
42
+ getStyles(): ClusterIconStyle[];
43
+ setStyles(styles: ClusterIconStyle[]): void;
44
+ getTitle(): string;
45
+ setTitle(title: string): void;
46
+ getZoomOnClick(): boolean;
47
+ setZoomOnClick(zoomOnClick: boolean): void;
48
+ getAverageCenter(): boolean;
49
+ setAverageCenter(averageCenter: boolean): void;
50
+ getIgnoreHidden(): boolean;
51
+ setIgnoreHidden(ignoreHidden: boolean): void;
52
+ getEnableRetinaIcons(): boolean;
53
+ setEnableRetinaIcons(enableRetinaIcons: boolean): void;
54
+ getImageExtension(): string;
55
+ setImageExtension(imageExtension: string): void;
56
+ getImagePath(): string;
57
+ setImagePath(imagePath: string): void;
58
+ getImageSizes(): number[];
59
+ setImageSizes(imageSizes: number[]): void;
60
+ getCalculator(): TCalculator;
61
+ setCalculator(calculator: TCalculator): void;
62
+ getBatchSizeIE(): number;
63
+ setBatchSizeIE(batchSizeIE: number): void;
64
+ getClusterClass(): string;
65
+ setClusterClass(clusterClass: string): void;
66
+ getMarkers(): MarkerExtended[];
67
+ getTotalMarkers(): number;
68
+ getClusters(): Cluster[];
69
+ getTotalClusters(): number;
70
+ addMarker(marker: MarkerExtended, optNoDraw: boolean): void;
71
+ addMarkers(markers: MarkerExtended[], optNoDraw: boolean): void;
72
+ pushMarkerTo(marker: MarkerExtended): void;
73
+ removeMarker_(marker: MarkerExtended): boolean;
74
+ removeMarker(marker: MarkerExtended, optNoDraw: boolean): boolean;
75
+ removeMarkers(markers: MarkerExtended[], optNoDraw: boolean): boolean;
76
+ clearMarkers(): void;
77
+ repaint(): void;
78
+ getExtendedBounds(bounds: google.maps.LatLngBounds): google.maps.LatLngBounds;
79
+ redraw(): void;
80
+ resetViewport(optHide: boolean): void;
81
+ distanceBetweenPoints(p1: google.maps.LatLng, p2: google.maps.LatLng): number;
82
+ isMarkerInBounds(marker: MarkerExtended, bounds: google.maps.LatLngBounds): boolean;
83
+ addToClosestCluster(marker: MarkerExtended): void;
84
+ createClusters(iFirst: number): void;
85
+ extend<A extends typeof ClusterIcon | typeof Clusterer>(obj1: A, obj2: typeof google.maps.OverlayView): A;
86
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+ export {};
package/dist/cjs.js CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var ClusterIcon = /** @class */ (function () {
6
4
  function ClusterIcon(cluster, styles) {
7
5
  cluster.getClusterer().extend(ClusterIcon, google.maps.OverlayView);
@@ -164,54 +162,33 @@ var ClusterIcon = /** @class */ (function () {
164
162
  this.visible = false;
165
163
  };
166
164
  ClusterIcon.prototype.show = function () {
167
- var _a;
165
+ var _a, _b, _c, _d;
168
166
  if (this.div && this.center) {
169
- var divTitle = '';
167
+ var divTitle = this.sums === null ||
168
+ typeof this.sums.title === 'undefined' ||
169
+ this.sums.title === '' ? this.cluster.getClusterer().getTitle() : this.sums.title;
170
170
  // NOTE: values must be specified in px units
171
171
  var bp = this.backgroundPosition.split(' ');
172
172
  var spriteH = parseInt(bp[0].replace(/^\s+|\s+$/g, ''), 10);
173
173
  var spriteV = parseInt(bp[1].replace(/^\s+|\s+$/g, ''), 10);
174
174
  var pos = this.getPosFromLatLng(this.center);
175
- if (this.sums === null ||
176
- typeof this.sums.title === 'undefined' ||
177
- this.sums.title === '') {
178
- divTitle = this.cluster.getClusterer().getTitle();
179
- }
180
- else {
181
- divTitle = this.sums.title;
182
- }
183
175
  this.div.className = this.className;
184
- this.div.style.cursor = 'pointer';
185
- this.div.style.position = 'absolute';
186
- this.div.style.top = pos !== null ? "".concat(pos.y, "px") : '0';
187
- this.div.style.left = pos !== null ? "".concat(pos.x, "px") : '0';
188
- this.div.style.width = "".concat(this.width, "px");
189
- this.div.style.height = "".concat(this.height, "px");
176
+ 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; "));
190
177
  var img = document.createElement('img');
191
178
  img.alt = divTitle;
192
179
  img.src = this.url;
193
180
  img.width = this.width;
194
181
  img.height = this.height;
195
- img.style.position = 'absolute';
196
- img.style.top = "".concat(spriteV, "px");
197
- img.style.left = "".concat(spriteH, "px");
182
+ img.setAttribute('style', "position: absolute; top: ".concat(spriteV, "px; left: ").concat(spriteH, "px"));
198
183
  if (!this.cluster.getClusterer().enableRetinaIcons) {
199
184
  img.style.clip = "rect(-".concat(spriteV, "px, -").concat(spriteH + this.width, "px, -").concat(spriteV + this.height, ", -").concat(spriteH, ")");
200
185
  }
201
186
  var textElm = document.createElement('div');
202
- textElm.style.position = 'absolute';
203
- textElm.style.top = "".concat(this.anchorText[0], "px");
204
- textElm.style.left = "".concat(this.anchorText[1], "px");
205
- textElm.style.color = this.textColor;
206
- textElm.style.fontSize = "".concat(this.textSize, "px");
207
- textElm.style.fontFamily = this.fontFamily;
208
- textElm.style.fontWeight = this.fontWeight;
209
- textElm.style.fontStyle = this.fontStyle;
210
- textElm.style.textDecoration = this.textDecoration;
211
- textElm.style.textAlign = 'center';
212
- textElm.style.width = "".concat(this.width, "px");
213
- textElm.style.lineHeight = "".concat(this.height, "px");
214
- textElm.innerText = "".concat((_a = this.sums) === null || _a === void 0 ? void 0 : _a.text);
187
+ 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"));
188
+ if ((_a = this.sums) === null || _a === void 0 ? void 0 : _a.text)
189
+ textElm.innerText = "".concat((_b = this.sums) === null || _b === void 0 ? void 0 : _b.text);
190
+ if ((_c = this.sums) === null || _c === void 0 ? void 0 : _c.html)
191
+ textElm.innerHTML = "".concat((_d = this.sums) === null || _d === void 0 ? void 0 : _d.html);
215
192
  this.div.innerHTML = '';
216
193
  this.div.appendChild(img);
217
194
  this.div.appendChild(textElm);
@@ -431,59 +408,60 @@ var Clusterer = /** @class */ (function () {
431
408
  function Clusterer(map, optMarkers, optOptions) {
432
409
  if (optMarkers === void 0) { optMarkers = []; }
433
410
  if (optOptions === void 0) { optOptions = {}; }
434
- this.onZoomChanged = this.onZoomChanged.bind(this);
435
- this.onIdle = this.onIdle.bind(this);
436
- this.onAdd = this.onAdd.bind(this);
437
- this.onRemove = this.onRemove.bind(this);
438
- this.draw = this.draw.bind(this);
439
- this.setupStyles = this.setupStyles.bind(this);
440
- this.fitMapToMarkers = this.fitMapToMarkers.bind(this);
441
- this.getGridSize = this.getGridSize.bind(this);
442
- this.setGridSize = this.setGridSize.bind(this);
443
411
  this.getMinimumClusterSize = this.getMinimumClusterSize.bind(this);
444
412
  this.setMinimumClusterSize = this.setMinimumClusterSize.bind(this);
445
- this.getMaxZoom = this.getMaxZoom.bind(this);
446
- this.setMaxZoom = this.setMaxZoom.bind(this);
447
- this.getStyles = this.getStyles.bind(this);
448
- this.setStyles = this.setStyles.bind(this);
449
- this.getTitle = this.getTitle.bind(this);
450
- this.setTitle = this.setTitle.bind(this);
451
- this.getZoomOnClick = this.getZoomOnClick.bind(this);
452
- this.setZoomOnClick = this.setZoomOnClick.bind(this);
453
- this.getAverageCenter = this.getAverageCenter.bind(this);
454
- this.setAverageCenter = this.setAverageCenter.bind(this);
455
- this.getIgnoreHidden = this.getIgnoreHidden.bind(this);
456
- this.setIgnoreHidden = this.setIgnoreHidden.bind(this);
457
413
  this.getEnableRetinaIcons = this.getEnableRetinaIcons.bind(this);
458
414
  this.setEnableRetinaIcons = this.setEnableRetinaIcons.bind(this);
415
+ this.addToClosestCluster = this.addToClosestCluster.bind(this);
459
416
  this.getImageExtension = this.getImageExtension.bind(this);
460
417
  this.setImageExtension = this.setImageExtension.bind(this);
461
- this.getImagePath = this.getImagePath.bind(this);
462
- this.setImagePath = this.setImagePath.bind(this);
418
+ this.getExtendedBounds = this.getExtendedBounds.bind(this);
419
+ this.getAverageCenter = this.getAverageCenter.bind(this);
420
+ this.setAverageCenter = this.setAverageCenter.bind(this);
421
+ this.getTotalClusters = this.getTotalClusters.bind(this);
422
+ this.fitMapToMarkers = this.fitMapToMarkers.bind(this);
423
+ this.getIgnoreHidden = this.getIgnoreHidden.bind(this);
424
+ this.setIgnoreHidden = this.setIgnoreHidden.bind(this);
425
+ this.getClusterClass = this.getClusterClass.bind(this);
426
+ this.setClusterClass = this.setClusterClass.bind(this);
427
+ this.getTotalMarkers = this.getTotalMarkers.bind(this);
428
+ this.getZoomOnClick = this.getZoomOnClick.bind(this);
429
+ this.setZoomOnClick = this.setZoomOnClick.bind(this);
430
+ this.getBatchSizeIE = this.getBatchSizeIE.bind(this);
431
+ this.setBatchSizeIE = this.setBatchSizeIE.bind(this);
432
+ this.createClusters = this.createClusters.bind(this);
433
+ this.onZoomChanged = this.onZoomChanged.bind(this);
463
434
  this.getImageSizes = this.getImageSizes.bind(this);
464
435
  this.setImageSizes = this.setImageSizes.bind(this);
465
436
  this.getCalculator = this.getCalculator.bind(this);
466
437
  this.setCalculator = this.setCalculator.bind(this);
467
- this.getBatchSizeIE = this.getBatchSizeIE.bind(this);
468
- this.setBatchSizeIE = this.setBatchSizeIE.bind(this);
469
- this.getClusterClass = this.getClusterClass.bind(this);
470
- this.setClusterClass = this.setClusterClass.bind(this);
471
- this.getMarkers = this.getMarkers.bind(this);
472
- this.getTotalMarkers = this.getTotalMarkers.bind(this);
473
- this.getClusters = this.getClusters.bind(this);
474
- this.getTotalClusters = this.getTotalClusters.bind(this);
475
- this.addMarker = this.addMarker.bind(this);
476
- this.addMarkers = this.addMarkers.bind(this);
438
+ this.removeMarkers = this.removeMarkers.bind(this);
439
+ this.resetViewport = this.resetViewport.bind(this);
440
+ this.getImagePath = this.getImagePath.bind(this);
441
+ this.setImagePath = this.setImagePath.bind(this);
477
442
  this.pushMarkerTo = this.pushMarkerTo.bind(this);
478
443
  this.removeMarker = this.removeMarker.bind(this);
479
- this.removeMarkers = this.removeMarkers.bind(this);
480
444
  this.clearMarkers = this.clearMarkers.bind(this);
445
+ this.setupStyles = this.setupStyles.bind(this);
446
+ this.getGridSize = this.getGridSize.bind(this);
447
+ this.setGridSize = this.setGridSize.bind(this);
448
+ this.getClusters = this.getClusters.bind(this);
449
+ this.getMaxZoom = this.getMaxZoom.bind(this);
450
+ this.setMaxZoom = this.setMaxZoom.bind(this);
451
+ this.getMarkers = this.getMarkers.bind(this);
452
+ this.addMarkers = this.addMarkers.bind(this);
453
+ this.getStyles = this.getStyles.bind(this);
454
+ this.setStyles = this.setStyles.bind(this);
455
+ this.addMarker = this.addMarker.bind(this);
456
+ this.onRemove = this.onRemove.bind(this);
457
+ this.getTitle = this.getTitle.bind(this);
458
+ this.setTitle = this.setTitle.bind(this);
481
459
  this.repaint = this.repaint.bind(this);
482
- this.getExtendedBounds = this.getExtendedBounds.bind(this);
460
+ this.onIdle = this.onIdle.bind(this);
483
461
  this.redraw = this.redraw.bind(this);
484
- this.resetViewport = this.resetViewport.bind(this);
485
- this.addToClosestCluster = this.addToClosestCluster.bind(this);
486
- this.createClusters = this.createClusters.bind(this);
462
+ this.extend = this.extend.bind(this);
463
+ this.onAdd = this.onAdd.bind(this);
464
+ this.draw = this.draw.bind(this);
487
465
  this.extend(Clusterer, google.maps.OverlayView);
488
466
  this.markers = [];
489
467
  this.clusters = [];
@@ -949,7 +927,8 @@ var Clusterer = /** @class */ (function () {
949
927
  Clusterer.prototype.extend = function (obj1, obj2) {
950
928
  return function applyExtend(object) {
951
929
  for (var property in object.prototype) {
952
- this.prototype.set(property, object.prototype.get(property));
930
+ // @ts-ignore
931
+ this.prototype[property] = object.prototype[property];
953
932
  }
954
933
  return this;
955
934
  }.apply(obj1, [obj2]);