@react-google-maps/marker-clusterer 2.6.0 → 2.10.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/esm.js CHANGED
@@ -22,7 +22,6 @@ var ClusterIcon = /** @class */ (function () {
22
22
  this.fontStyle = 'normal';
23
23
  this.fontFamily = 'Arial,sans-serif';
24
24
  this.backgroundPosition = '0 0';
25
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
26
25
  // @ts-ignore
27
26
  this.setMap(cluster.getMap()); // Note: this causes onAdd to be called
28
27
  }
@@ -35,24 +34,19 @@ var ClusterIcon = /** @class */ (function () {
35
34
  if (this.visible) {
36
35
  this.show();
37
36
  }
38
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
39
37
  // @ts-ignore
40
38
  this.getPanes().overlayMouseTarget.appendChild(this.div);
41
39
  // Fix for Issue 157
42
40
  this.boundsChangedListener = google.maps.event.addListener(
43
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
44
41
  // @ts-ignore
45
42
  this.getMap(), 'boundschanged', function boundsChanged() {
46
43
  cDraggingMapByCluster = cMouseDownInCluster;
47
44
  });
48
- google.maps.event.addDomListener(this.div, 'mousedown', function onMouseDown() {
45
+ google.maps.event.addListener(this.div, 'mousedown', function onMouseDown() {
49
46
  cMouseDownInCluster = true;
50
47
  cDraggingMapByCluster = false;
51
48
  });
52
- // eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
53
- google.maps.event.addDomListener(this.div, 'click',
54
- // eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
55
- function (event) {
49
+ google.maps.event.addListener(this.div, 'click', function (event) {
56
50
  cMouseDownInCluster = false;
57
51
  if (!cDraggingMapByCluster) {
58
52
  var markerClusterer_1 = _this.cluster.getClusterer();
@@ -70,19 +64,15 @@ var ClusterIcon = /** @class */ (function () {
70
64
  // Zoom into the cluster.
71
65
  var maxZoom_1 = markerClusterer_1.getMaxZoom();
72
66
  var bounds_1 = _this.cluster.getBounds();
73
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
74
67
  // @ts-ignore
75
68
  markerClusterer_1.getMap().fitBounds(bounds_1);
76
69
  // There is a fix for Issue 170 here:
77
70
  setTimeout(function timeout() {
78
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
79
71
  // @ts-ignore
80
72
  markerClusterer_1.getMap().fitBounds(bounds_1);
81
73
  // Don't zoom beyond the max zoom level
82
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
83
74
  // @ts-ignore
84
75
  if (maxZoom_1 !== null && markerClusterer_1.getMap().getZoom() > maxZoom_1) {
85
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
86
76
  // @ts-ignore
87
77
  markerClusterer_1.getMap().setZoom(maxZoom_1 + 1);
88
78
  }
@@ -95,9 +85,7 @@ var ClusterIcon = /** @class */ (function () {
95
85
  }
96
86
  }
97
87
  });
98
- google.maps.event.addDomListener(this.div, 'mouseover',
99
- // eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
100
- function () {
88
+ google.maps.event.addListener(this.div, 'mouseover', function () {
101
89
  /**
102
90
  * This event is fired when the mouse moves over a cluster marker.
103
91
  * @name MarkerClusterer#mouseover
@@ -106,10 +94,7 @@ var ClusterIcon = /** @class */ (function () {
106
94
  */
107
95
  google.maps.event.trigger(_this.cluster.getClusterer(), 'mouseover', _this.cluster);
108
96
  });
109
- // eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
110
- google.maps.event.addDomListener(this.div, 'mouseout',
111
- // eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
112
- function () {
97
+ google.maps.event.addListener(this.div, 'mouseout', function () {
113
98
  /**
114
99
  * This event is fired when the mouse moves out of a cluster marker.
115
100
  * @name MarkerClusterer#mouseout
@@ -144,8 +129,9 @@ var ClusterIcon = /** @class */ (function () {
144
129
  this.visible = false;
145
130
  };
146
131
  ClusterIcon.prototype.show = function () {
132
+ var _a;
147
133
  if (this.div && this.center) {
148
- var img = '', divTitle = '';
134
+ var divTitle = '';
149
135
  // NOTE: values must be specified in px units
150
136
  var bp = this.backgroundPosition.split(' ');
151
137
  var spriteH = parseInt(bp[0].replace(/^\s+|\s+$/g, ''), 10);
@@ -157,72 +143,38 @@ var ClusterIcon = /** @class */ (function () {
157
143
  else {
158
144
  divTitle = this.sums.title;
159
145
  }
160
- this.div.style.cssText = this.createCss(pos);
161
- img =
162
- "<img alt='" +
163
- divTitle +
164
- "' src='" +
165
- this.url +
166
- "' style='position: absolute; top: " +
167
- spriteV +
168
- 'px; left: ' +
169
- spriteH +
170
- 'px; ';
171
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
172
- //@ts-ignore
146
+ this.div.style.cursor = 'pointer';
147
+ this.div.style.position = 'absolute';
148
+ this.div.style.top = "".concat(pos.y, "px");
149
+ this.div.style.left = "".concat(pos.x, "px");
150
+ this.div.style.width = "".concat(this.width, "px");
151
+ this.div.style.height = "".concat(this.height, "px");
152
+ var img = document.createElement('img');
153
+ img.alt = divTitle;
154
+ img.src = this.url;
155
+ img.style.position = 'absolute';
156
+ img.style.top = "".concat(spriteV, "px");
157
+ img.style.left = "".concat(spriteH, "px");
173
158
  if (!this.cluster.getClusterer().enableRetinaIcons) {
174
- img +=
175
- 'clip: rect(' +
176
- -1 * spriteV +
177
- 'px, ' +
178
- (-1 * spriteH + this.width) +
179
- 'px, ' +
180
- (-1 * spriteV + this.height) +
181
- 'px, ' +
182
- -1 * spriteH +
183
- 'px);';
159
+ img.style.clip = "rect(-".concat(spriteV, "px, -").concat(spriteH + this.width, "px, -").concat(spriteV + this.height, ", -").concat(spriteH, ")");
184
160
  }
185
- img += "'>";
186
- this.div.innerHTML =
187
- img +
188
- "<div style='" +
189
- 'position: absolute;' +
190
- 'top: ' +
191
- this.anchorText[0] +
192
- 'px;' +
193
- 'left: ' +
194
- this.anchorText[1] +
195
- 'px;' +
196
- 'color: ' +
197
- this.textColor +
198
- ';' +
199
- 'font-size: ' +
200
- this.textSize +
201
- 'px;' +
202
- 'font-family: ' +
203
- this.fontFamily +
204
- ';' +
205
- 'font-weight: ' +
206
- this.fontWeight +
207
- ';' +
208
- 'font-style: ' +
209
- this.fontStyle +
210
- ';' +
211
- 'text-decoration: ' +
212
- this.textDecoration +
213
- ';' +
214
- 'text-align: center;' +
215
- 'width: ' +
216
- this.width +
217
- 'px;' +
218
- 'line-height:' +
219
- this.height +
220
- 'px;' +
221
- "'>" +
222
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
223
- // @ts-ignore
224
- this.sums.text +
225
- '</div>';
161
+ var textElm = document.createElement('div');
162
+ textElm.style.position = 'absolute';
163
+ textElm.style.top = "".concat(this.anchorText[0], "px");
164
+ textElm.style.left = "".concat(this.anchorText[1], "px");
165
+ textElm.style.color = this.textColor;
166
+ textElm.style.fontSize = "".concat(this.textSize, "px");
167
+ textElm.style.fontFamily = this.fontFamily;
168
+ textElm.style.fontWeight = this.fontWeight;
169
+ textElm.style.fontStyle = this.fontStyle;
170
+ textElm.style.textDecoration = this.textDecoration;
171
+ textElm.style.textAlign = 'center';
172
+ textElm.style.width = "".concat(this.width, "px");
173
+ textElm.style.lineHeight = "".concat(this.height, "px");
174
+ textElm.innerText = "".concat((_a = this.sums) === null || _a === void 0 ? void 0 : _a.text);
175
+ this.div.innerHTML = '';
176
+ this.div.appendChild(img);
177
+ this.div.appendChild(textElm);
226
178
  this.div.title = divTitle;
227
179
  this.div.style.display = '';
228
180
  }
@@ -236,7 +188,7 @@ var ClusterIcon = /** @class */ (function () {
236
188
  this.height = style.height;
237
189
  this.width = style.width;
238
190
  if (style.className)
239
- this.className = this.clusterClassName + " " + style.className;
191
+ this.className = "".concat(this.clusterClassName, " ").concat(style.className);
240
192
  this.anchorText = style.anchorText || [0, 0];
241
193
  this.anchorIcon = style.anchorIcon || [this.height / 2, this.width / 2];
242
194
  this.textColor = style.textColor || 'black';
@@ -250,15 +202,7 @@ var ClusterIcon = /** @class */ (function () {
250
202
  ClusterIcon.prototype.setCenter = function (center) {
251
203
  this.center = center;
252
204
  };
253
- ClusterIcon.prototype.createCss = function (pos) {
254
- var style = [];
255
- style.push('cursor: pointer;');
256
- style.push('position: absolute; top: ' + pos.y + 'px; left: ' + pos.x + 'px;');
257
- style.push('width: ' + this.width + 'px; height: ' + this.height + 'px;');
258
- return style.join('');
259
- };
260
205
  ClusterIcon.prototype.getPosFromLatLng = function (latlng) {
261
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
262
206
  // @ts-ignore
263
207
  var pos = this.getProjection().fromLatLngToDivPixel(latlng);
264
208
  pos.x -= this.anchorIcon[1];
@@ -273,7 +217,7 @@ var ClusterIcon = /** @class */ (function () {
273
217
  var Cluster = /** @class */ (function () {
274
218
  function Cluster(markerClusterer) {
275
219
  this.markerClusterer = markerClusterer;
276
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
220
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
277
221
  // @ts-ignore
278
222
  this.map = this.markerClusterer.getMap();
279
223
  this.gridSize = this.markerClusterer.getGridSize();
@@ -311,10 +255,11 @@ var Cluster = /** @class */ (function () {
311
255
  return bounds;
312
256
  };
313
257
  Cluster.prototype.remove = function () {
314
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
258
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
315
259
  // @ts-ignore
316
260
  this.clusterIcon.setMap(null);
317
261
  this.markers = [];
262
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
318
263
  // @ts-ignore
319
264
  delete this.markers;
320
265
  };
@@ -402,11 +347,9 @@ var Cluster = /** @class */ (function () {
402
347
  if (this.markers.includes) {
403
348
  return this.markers.includes(marker);
404
349
  }
405
- else {
406
- for (var i = 0; i < this.markers.length; i++) {
407
- if (marker === this.markers[i]) {
408
- return true;
409
- }
350
+ for (var i = 0; i < this.markers.length; i++) {
351
+ if (marker === this.markers[i]) {
352
+ return true;
410
353
  }
411
354
  }
412
355
  return false;
@@ -480,13 +423,13 @@ var Clusterer = /** @class */ (function () {
480
423
  this.timerRefStatic = null;
481
424
  this.setupStyles();
482
425
  this.addMarkers(optMarkers, true);
483
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
426
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
484
427
  // @ts-ignore
485
428
  this.setMap(map); // Note: this causes onAdd to be called
486
429
  }
487
430
  Clusterer.prototype.onAdd = function () {
488
431
  var _this = this;
489
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
432
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
490
433
  // @ts-ignore
491
434
  this.activeMap = this.getMap();
492
435
  this.ready = true;
@@ -494,11 +437,9 @@ var Clusterer = /** @class */ (function () {
494
437
  // Add the map event listeners
495
438
  this.listeners = [
496
439
  google.maps.event.addListener(
497
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
440
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
498
441
  // @ts-ignore
499
- this.getMap(), 'zoom_changed',
500
- // eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
501
- function () {
442
+ this.getMap(), 'zoom_changed', function () {
502
443
  _this.resetViewport(false);
503
444
  // Workaround for this Google bug: when map is at level 0 and "-" of
504
445
  // zoom slider is clicked, a "zoom_changed" event is fired even though
@@ -506,26 +447,23 @@ var Clusterer = /** @class */ (function () {
506
447
  // event is triggered so the cluster markers that have been removed
507
448
  // do not get redrawn. Same goes for a zoom in at maxZoom.
508
449
  if (
509
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
450
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
510
451
  // @ts-ignore
511
452
  _this.getMap().getZoom() === (_this.get('minZoom') || 0) ||
512
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
453
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
513
454
  // @ts-ignore
514
455
  _this.getMap().getZoom() === _this.get('maxZoom')) {
515
456
  google.maps.event.trigger(_this, 'idle');
516
457
  }
517
458
  }),
518
459
  google.maps.event.addListener(
519
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
460
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
520
461
  // @ts-ignore
521
- this.getMap(), 'idle',
522
- // eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
523
- function () {
462
+ this.getMap(), 'idle', function () {
524
463
  _this.redraw();
525
464
  }),
526
465
  ];
527
466
  };
528
- // eslint-disable-next-line @getify/proper-arrows/this
529
467
  Clusterer.prototype.onRemove = function () {
530
468
  // Put all the managed markers back on the map:
531
469
  for (var i = 0; i < this.markers.length; i++) {
@@ -569,7 +507,7 @@ var Clusterer = /** @class */ (function () {
569
507
  bounds.extend(position);
570
508
  }
571
509
  }
572
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
510
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
573
511
  // @ts-ignore
574
512
  this.getMap().fitBounds(bounds);
575
513
  };
@@ -683,7 +621,7 @@ var Clusterer = /** @class */ (function () {
683
621
  };
684
622
  Clusterer.prototype.addMarkers = function (markers, optNoDraw) {
685
623
  for (var key in markers) {
686
- if (markers.hasOwnProperty(key)) {
624
+ if (Object.prototype.hasOwnProperty.call(markers, key)) {
687
625
  this.pushMarkerTo(markers[key]);
688
626
  }
689
627
  }
@@ -695,7 +633,6 @@ var Clusterer = /** @class */ (function () {
695
633
  var _this = this;
696
634
  // If the marker is draggable add a listener so we can update the clusters on the dragend:
697
635
  if (marker.getDraggable()) {
698
- // eslint-disable-next-line @getify/proper-arrows/name, @getify/proper-arrows/this
699
636
  google.maps.event.addListener(marker, 'dragend', function () {
700
637
  if (_this.ready) {
701
638
  marker.isAdded = false;
@@ -762,7 +699,7 @@ var Clusterer = /** @class */ (function () {
762
699
  }, 0);
763
700
  };
764
701
  Clusterer.prototype.getExtendedBounds = function (bounds) {
765
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
702
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
766
703
  // @ts-ignore
767
704
  var projection = this.getProjection();
768
705
  // Convert the points to pixels and the extend out by the grid size.
@@ -864,6 +801,7 @@ var Clusterer = /** @class */ (function () {
864
801
  google.maps.event.trigger(this, 'clusteringbegin', this);
865
802
  if (this.timerRefStatic !== null) {
866
803
  window.clearTimeout(this.timerRefStatic);
804
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
867
805
  // @ts-ignore
868
806
  delete this.timerRefStatic;
869
807
  }
@@ -873,16 +811,16 @@ var Clusterer = /** @class */ (function () {
873
811
  //
874
812
  // See Comments 9 & 11 on Issue 3651 relating to this workaround for a Google Maps bug:
875
813
  var mapBounds =
876
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
814
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
877
815
  // @ts-ignore
878
816
  this.getMap().getZoom() > 3
879
817
  ? new google.maps.LatLngBounds(
880
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
818
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
881
819
  // @ts-ignore
882
820
  this.getMap()
883
821
  .getBounds()
884
822
  .getSouthWest(),
885
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
823
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
886
824
  // @ts-ignore
887
825
  this.getMap()
888
826
  .getBounds()
@@ -892,16 +830,12 @@ var Clusterer = /** @class */ (function () {
892
830
  var iLast = Math.min(iFirst + this.batchSize, this.markers.length);
893
831
  for (var i = iFirst; i < iLast; i++) {
894
832
  var marker = this.markers[i];
895
- if (!marker.isAdded && this.isMarkerInBounds(marker, bounds)) {
896
- if (!this.ignoreHidden || (this.ignoreHidden && marker.getVisible())) {
897
- this.addToClosestCluster(marker);
898
- }
833
+ if (!marker.isAdded && this.isMarkerInBounds(marker, bounds) && (!this.ignoreHidden || (this.ignoreHidden && marker.getVisible()))) {
834
+ this.addToClosestCluster(marker);
899
835
  }
900
836
  }
901
837
  if (iLast < this.markers.length) {
902
- this.timerRefStatic = window.setTimeout(
903
- // eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
904
- function () {
838
+ this.timerRefStatic = window.setTimeout(function () {
905
839
  _this.createClusters(iLast);
906
840
  }, 0);
907
841
  }
@@ -924,11 +858,11 @@ var Clusterer = /** @class */ (function () {
924
858
  return function applyExtend(object) {
925
859
  // eslint-disable-next-line guard-for-in
926
860
  for (var property in object.prototype) {
927
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
861
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
928
862
  // @ts-ignore
929
863
  this.prototype[property] = object.prototype[property];
930
864
  }
931
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
865
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
932
866
  // @ts-ignore
933
867
  return this;
934
868
  }.apply(obj1, [obj2]);