@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/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,24 +38,19 @@ 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;
51
48
  });
52
- google.maps.event.addDomListener(this.div, 'mousedown', function onMouseDown() {
49
+ google.maps.event.addListener(this.div, 'mousedown', function onMouseDown() {
53
50
  cMouseDownInCluster = true;
54
51
  cDraggingMapByCluster = false;
55
52
  });
56
- // eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
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.addListener(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.addListener(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
- // eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
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.addListener(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 img = '', divTitle = '';
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.cssText = this.createCss(pos);
165
- img =
166
- "<img alt='" +
167
- divTitle +
168
- "' src='" +
169
- this.url +
170
- "' style='position: absolute; top: " +
171
- spriteV +
172
- 'px; left: ' +
173
- spriteH +
174
- 'px; ';
175
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
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
- img += "'>";
190
- this.div.innerHTML =
191
- img +
192
- "<div style='" +
193
- 'position: absolute;' +
194
- 'top: ' +
195
- this.anchorText[0] +
196
- 'px;' +
197
- 'left: ' +
198
- this.anchorText[1] +
199
- 'px;' +
200
- 'color: ' +
201
- this.textColor +
202
- ';' +
203
- 'font-size: ' +
204
- this.textSize +
205
- 'px;' +
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 + " " + style.className;
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,7 @@ 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
224
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
281
225
  // @ts-ignore
282
226
  this.map = this.markerClusterer.getMap();
283
227
  this.gridSize = this.markerClusterer.getGridSize();
@@ -315,10 +259,11 @@ var Cluster = /** @class */ (function () {
315
259
  return bounds;
316
260
  };
317
261
  Cluster.prototype.remove = function () {
318
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
262
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
319
263
  // @ts-ignore
320
264
  this.clusterIcon.setMap(null);
321
265
  this.markers = [];
266
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
322
267
  // @ts-ignore
323
268
  delete this.markers;
324
269
  };
@@ -406,11 +351,9 @@ var Cluster = /** @class */ (function () {
406
351
  if (this.markers.includes) {
407
352
  return this.markers.includes(marker);
408
353
  }
409
- else {
410
- for (var i = 0; i < this.markers.length; i++) {
411
- if (marker === this.markers[i]) {
412
- return true;
413
- }
354
+ for (var i = 0; i < this.markers.length; i++) {
355
+ if (marker === this.markers[i]) {
356
+ return true;
414
357
  }
415
358
  }
416
359
  return false;
@@ -484,13 +427,13 @@ var Clusterer = /** @class */ (function () {
484
427
  this.timerRefStatic = null;
485
428
  this.setupStyles();
486
429
  this.addMarkers(optMarkers, true);
487
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
430
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
488
431
  // @ts-ignore
489
432
  this.setMap(map); // Note: this causes onAdd to be called
490
433
  }
491
434
  Clusterer.prototype.onAdd = function () {
492
435
  var _this = this;
493
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
436
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
494
437
  // @ts-ignore
495
438
  this.activeMap = this.getMap();
496
439
  this.ready = true;
@@ -498,11 +441,9 @@ var Clusterer = /** @class */ (function () {
498
441
  // Add the map event listeners
499
442
  this.listeners = [
500
443
  google.maps.event.addListener(
501
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
444
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
502
445
  // @ts-ignore
503
- this.getMap(), 'zoom_changed',
504
- // eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
505
- function () {
446
+ this.getMap(), 'zoom_changed', function () {
506
447
  _this.resetViewport(false);
507
448
  // Workaround for this Google bug: when map is at level 0 and "-" of
508
449
  // zoom slider is clicked, a "zoom_changed" event is fired even though
@@ -510,26 +451,23 @@ var Clusterer = /** @class */ (function () {
510
451
  // event is triggered so the cluster markers that have been removed
511
452
  // do not get redrawn. Same goes for a zoom in at maxZoom.
512
453
  if (
513
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
454
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
514
455
  // @ts-ignore
515
456
  _this.getMap().getZoom() === (_this.get('minZoom') || 0) ||
516
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
457
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
517
458
  // @ts-ignore
518
459
  _this.getMap().getZoom() === _this.get('maxZoom')) {
519
460
  google.maps.event.trigger(_this, 'idle');
520
461
  }
521
462
  }),
522
463
  google.maps.event.addListener(
523
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
464
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
524
465
  // @ts-ignore
525
- this.getMap(), 'idle',
526
- // eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
527
- function () {
466
+ this.getMap(), 'idle', function () {
528
467
  _this.redraw();
529
468
  }),
530
469
  ];
531
470
  };
532
- // eslint-disable-next-line @getify/proper-arrows/this
533
471
  Clusterer.prototype.onRemove = function () {
534
472
  // Put all the managed markers back on the map:
535
473
  for (var i = 0; i < this.markers.length; i++) {
@@ -573,7 +511,7 @@ var Clusterer = /** @class */ (function () {
573
511
  bounds.extend(position);
574
512
  }
575
513
  }
576
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
514
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
577
515
  // @ts-ignore
578
516
  this.getMap().fitBounds(bounds);
579
517
  };
@@ -687,7 +625,7 @@ var Clusterer = /** @class */ (function () {
687
625
  };
688
626
  Clusterer.prototype.addMarkers = function (markers, optNoDraw) {
689
627
  for (var key in markers) {
690
- if (markers.hasOwnProperty(key)) {
628
+ if (Object.prototype.hasOwnProperty.call(markers, key)) {
691
629
  this.pushMarkerTo(markers[key]);
692
630
  }
693
631
  }
@@ -699,7 +637,6 @@ var Clusterer = /** @class */ (function () {
699
637
  var _this = this;
700
638
  // If the marker is draggable add a listener so we can update the clusters on the dragend:
701
639
  if (marker.getDraggable()) {
702
- // eslint-disable-next-line @getify/proper-arrows/name, @getify/proper-arrows/this
703
640
  google.maps.event.addListener(marker, 'dragend', function () {
704
641
  if (_this.ready) {
705
642
  marker.isAdded = false;
@@ -766,7 +703,7 @@ var Clusterer = /** @class */ (function () {
766
703
  }, 0);
767
704
  };
768
705
  Clusterer.prototype.getExtendedBounds = function (bounds) {
769
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
706
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
770
707
  // @ts-ignore
771
708
  var projection = this.getProjection();
772
709
  // Convert the points to pixels and the extend out by the grid size.
@@ -868,6 +805,7 @@ var Clusterer = /** @class */ (function () {
868
805
  google.maps.event.trigger(this, 'clusteringbegin', this);
869
806
  if (this.timerRefStatic !== null) {
870
807
  window.clearTimeout(this.timerRefStatic);
808
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
871
809
  // @ts-ignore
872
810
  delete this.timerRefStatic;
873
811
  }
@@ -877,16 +815,16 @@ var Clusterer = /** @class */ (function () {
877
815
  //
878
816
  // See Comments 9 & 11 on Issue 3651 relating to this workaround for a Google Maps bug:
879
817
  var mapBounds =
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().getZoom() > 3
883
821
  ? new google.maps.LatLngBounds(
884
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
822
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
885
823
  // @ts-ignore
886
824
  this.getMap()
887
825
  .getBounds()
888
826
  .getSouthWest(),
889
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
827
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
890
828
  // @ts-ignore
891
829
  this.getMap()
892
830
  .getBounds()
@@ -896,16 +834,12 @@ var Clusterer = /** @class */ (function () {
896
834
  var iLast = Math.min(iFirst + this.batchSize, this.markers.length);
897
835
  for (var i = iFirst; i < iLast; i++) {
898
836
  var marker = this.markers[i];
899
- if (!marker.isAdded && this.isMarkerInBounds(marker, bounds)) {
900
- if (!this.ignoreHidden || (this.ignoreHidden && marker.getVisible())) {
901
- this.addToClosestCluster(marker);
902
- }
837
+ if (!marker.isAdded && this.isMarkerInBounds(marker, bounds) && (!this.ignoreHidden || (this.ignoreHidden && marker.getVisible()))) {
838
+ this.addToClosestCluster(marker);
903
839
  }
904
840
  }
905
841
  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 () {
842
+ this.timerRefStatic = window.setTimeout(function () {
909
843
  _this.createClusters(iLast);
910
844
  }, 0);
911
845
  }
@@ -928,11 +862,11 @@ var Clusterer = /** @class */ (function () {
928
862
  return function applyExtend(object) {
929
863
  // eslint-disable-next-line guard-for-in
930
864
  for (var property in object.prototype) {
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
  this.prototype[property] = object.prototype[property];
934
868
  }
935
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
869
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
936
870
  // @ts-ignore
937
871
  return this;
938
872
  }.apply(obj1, [obj2]);