@react-google-maps/marker-clusterer 2.6.0 → 2.8.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/src/Clusterer.tsx CHANGED
@@ -26,7 +26,7 @@ const CALCULATOR = function CALCULATOR(
26
26
 
27
27
  return {
28
28
  text: count.toString(),
29
- index: index,
29
+ index,
30
30
  title: '',
31
31
  }
32
32
  }
@@ -134,13 +134,11 @@ export class Clusterer {
134
134
  this.setupStyles()
135
135
 
136
136
  this.addMarkers(optMarkers, true)
137
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
138
137
  // @ts-ignore
139
138
  this.setMap(map) // Note: this causes onAdd to be called
140
139
  }
141
140
 
142
141
  onAdd() {
143
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
144
142
  // @ts-ignore
145
143
  this.activeMap = this.getMap()
146
144
 
@@ -151,11 +149,9 @@ export class Clusterer {
151
149
  // Add the map event listeners
152
150
  this.listeners = [
153
151
  google.maps.event.addListener(
154
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
155
152
  // @ts-ignore
156
153
  this.getMap(),
157
154
  'zoom_changed',
158
- // eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
159
155
  () => {
160
156
  this.resetViewport(false)
161
157
  // Workaround for this Google bug: when map is at level 0 and "-" of
@@ -164,10 +160,8 @@ export class Clusterer {
164
160
  // event is triggered so the cluster markers that have been removed
165
161
  // do not get redrawn. Same goes for a zoom in at maxZoom.
166
162
  if (
167
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
168
163
  // @ts-ignore
169
164
  this.getMap().getZoom() === (this.get('minZoom') || 0) ||
170
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
171
165
  // @ts-ignore
172
166
  this.getMap().getZoom() === this.get('maxZoom')
173
167
  ) {
@@ -176,11 +170,9 @@ export class Clusterer {
176
170
  }
177
171
  ),
178
172
  google.maps.event.addListener(
179
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
180
173
  // @ts-ignore
181
174
  this.getMap(),
182
175
  'idle',
183
- // eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
184
176
  () => {
185
177
  this.redraw()
186
178
  }
@@ -188,7 +180,6 @@ export class Clusterer {
188
180
  ]
189
181
  }
190
182
 
191
- // eslint-disable-next-line @getify/proper-arrows/this
192
183
  onRemove() {
193
184
  // Put all the managed markers back on the map:
194
185
  for (let i = 0; i < this.markers.length; i++) {
@@ -245,7 +236,6 @@ export class Clusterer {
245
236
  }
246
237
  }
247
238
 
248
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
249
239
  // @ts-ignore
250
240
  this.getMap().fitBounds(bounds)
251
241
  }
@@ -396,7 +386,7 @@ export class Clusterer {
396
386
 
397
387
  addMarkers(markers: MarkerExtended[], optNoDraw: boolean) {
398
388
  for (const key in markers) {
399
- if (markers.hasOwnProperty(key)) {
389
+ if (Object.prototype.hasOwnProperty.call(markers, key)) {
400
390
  this.pushMarkerTo(markers[key])
401
391
  }
402
392
  }
@@ -409,7 +399,6 @@ export class Clusterer {
409
399
  pushMarkerTo(marker: MarkerExtended) {
410
400
  // If the marker is draggable add a listener so we can update the clusters on the dragend:
411
401
  if (marker.getDraggable()) {
412
- // eslint-disable-next-line @getify/proper-arrows/name, @getify/proper-arrows/this
413
402
  google.maps.event.addListener(marker, 'dragend', () => {
414
403
  if (this.ready) {
415
404
  marker.isAdded = false
@@ -500,7 +489,6 @@ export class Clusterer {
500
489
  }
501
490
 
502
491
  getExtendedBounds(bounds: google.maps.LatLngBounds): google.maps.LatLngBounds {
503
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
504
492
  // @ts-ignore
505
493
  const projection = this.getProjection()
506
494
  // Convert the points to pixels and the extend out by the grid size.
@@ -650,16 +638,13 @@ export class Clusterer {
650
638
  //
651
639
  // See Comments 9 & 11 on Issue 3651 relating to this workaround for a Google Maps bug:
652
640
  const mapBounds =
653
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
654
641
  // @ts-ignore
655
642
  this.getMap().getZoom() > 3
656
643
  ? new google.maps.LatLngBounds(
657
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
658
644
  // @ts-ignore
659
645
  this.getMap()
660
646
  .getBounds()
661
647
  .getSouthWest(),
662
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
663
648
  // @ts-ignore
664
649
  this.getMap()
665
650
  .getBounds()
@@ -686,7 +671,6 @@ export class Clusterer {
686
671
 
687
672
  if (iLast < this.markers.length) {
688
673
  this.timerRefStatic = window.setTimeout(
689
- // eslint-disable-next-line @getify/proper-arrows/this, @getify/proper-arrows/name
690
674
  () => {
691
675
  this.createClusters(iLast)
692
676
  },
@@ -714,12 +698,10 @@ export class Clusterer {
714
698
  return function applyExtend(object: any) {
715
699
  // eslint-disable-next-line guard-for-in
716
700
  for (const property in object.prototype) {
717
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
718
701
  // @ts-ignore
719
702
  this.prototype[property] = object.prototype[property]
720
703
  }
721
704
 
722
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
723
705
  // @ts-ignore
724
706
  return this
725
707
  }.apply(obj1, [obj2])
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+
1
5
  import { Clusterer } from '../Clusterer'
2
6
 
3
7
  describe('Clusterer', () => {
package/src/types.tsx CHANGED
@@ -11,6 +11,22 @@ export type MarkerExtended = google.maps.Marker & {
11
11
 
12
12
  export type TCalculator = (markers: MarkerExtended[], num: number) => ClusterIconInfo
13
13
 
14
+ export interface ClusterIconStyle {
15
+ url: string
16
+ className?: string
17
+ height: number
18
+ width: number
19
+ anchorText?: number[]
20
+ anchorIcon?: number[]
21
+ textColor?: string
22
+ textSize?: number
23
+ textDecoration?: string
24
+ fontWeight?: string
25
+ fontStyle?: string
26
+ fontFamily?: string
27
+ backgroundPosition?: string
28
+ }
29
+
14
30
  export interface ClustererOptions {
15
31
  gridSize?: number
16
32
  maxZoom?: number
@@ -29,19 +45,3 @@ export interface ClustererOptions {
29
45
  imageExtension?: string
30
46
  imageSizes?: number[]
31
47
  }
32
-
33
- export interface ClusterIconStyle {
34
- url: string
35
- className?: string
36
- height: number
37
- width: number
38
- anchorText?: number[]
39
- anchorIcon?: number[]
40
- textColor?: string
41
- textSize?: number
42
- textDecoration?: string
43
- fontWeight?: string
44
- fontStyle?: string
45
- fontFamily?: string
46
- backgroundPosition?: string
47
- }