@react-google-maps/marker-clusterer 2.11.0 → 2.11.3

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
@@ -45,7 +45,7 @@ const IMAGE_SIZES = [53, 56, 66, 78, 90]
45
45
 
46
46
  const CLUSTERER_CLASS = 'cluster'
47
47
 
48
- export class Clusterer extends google.maps.OverlayView {
48
+ export class Clusterer {
49
49
  markers: MarkerExtended[]
50
50
  clusters: Cluster[]
51
51
  listeners: google.maps.MapsEventListener[]
@@ -74,8 +74,6 @@ export class Clusterer extends google.maps.OverlayView {
74
74
  optMarkers: MarkerExtended[] = [],
75
75
  optOptions: ClustererOptions = {}
76
76
  ) {
77
- super()
78
-
79
77
  this.extend(Clusterer, google.maps.OverlayView)
80
78
 
81
79
  this.markers = []
@@ -136,10 +134,9 @@ export class Clusterer extends google.maps.OverlayView {
136
134
 
137
135
  this.setupStyles()
138
136
 
139
- this.addMarkers(optMarkers, true)
140
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
141
- // @ts-ignore
142
- this.setMap(map) // Note: this causes onAdd to be called
137
+ this.addMarkers(optMarkers, true);
138
+
139
+ (this as unknown as google.maps.OverlayView).setMap(map) // Note: this causes onAdd to be called
143
140
  }
144
141
 
145
142
  onZoomChanged() {
@@ -151,9 +148,8 @@ export class Clusterer extends google.maps.OverlayView {
151
148
  // event is triggered so the cluster markers that have been removed
152
149
  // do not get redrawn. Same goes for a zoom in at maxZoom.
153
150
  if (
154
- this.getMap()?.getZoom() === (this.get('minZoom') || 0) ||
155
-
156
- this.getMap()?.getZoom() === this.get('maxZoom')
151
+ (this as unknown as google.maps.OverlayView).getMap()?.getZoom() === ((this as unknown as google.maps.OverlayView).get('minZoom') || 0) ||
152
+ (this as unknown as google.maps.OverlayView).getMap()?.getZoom() === (this as unknown as google.maps.OverlayView).get('maxZoom')
157
153
  ) {
158
154
  google.maps.event.trigger(this, 'idle')
159
155
  }
@@ -164,7 +160,7 @@ export class Clusterer extends google.maps.OverlayView {
164
160
  }
165
161
 
166
162
  onAdd() {
167
- const map = this.getMap()
163
+ const map = (this as unknown as google.maps.OverlayView).getMap()
168
164
 
169
165
  this.activeMap = map
170
166
 
@@ -240,14 +236,18 @@ export class Clusterer extends google.maps.OverlayView {
240
236
 
241
237
  for (let i = 0; i < markers.length; i++) {
242
238
  const position = markers[i].getPosition()
239
+
243
240
  if (position) {
244
241
  bounds.extend(position)
245
242
  }
246
243
  }
247
244
 
248
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
249
- // @ts-ignore
250
- this.getMap().fitBounds(bounds)
245
+ const map = (this as unknown as google.maps.OverlayView).getMap()
246
+
247
+ if (map !== null && 'fitBounds' in map) {
248
+ map.fitBounds(bounds)
249
+ }
250
+
251
251
  }
252
252
 
253
253
  getGridSize(): number {
@@ -499,9 +499,8 @@ export class Clusterer extends google.maps.OverlayView {
499
499
  }
500
500
 
501
501
  getExtendedBounds(bounds: google.maps.LatLngBounds): google.maps.LatLngBounds {
502
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
503
- // @ts-ignore
504
- const projection = this.getProjection()
502
+ const projection = (this as unknown as google.maps.OverlayView).getProjection()
503
+
505
504
  // Convert the points to pixels and the extend out by the grid size.
506
505
  const trPix = projection.fromLatLngToDivPixel(
507
506
  // Turn the bounds into latlng.
@@ -661,18 +660,16 @@ export class Clusterer extends google.maps.OverlayView {
661
660
  }
662
661
  }
663
662
 
664
- const map = this.getMap()
663
+ const map = (this as unknown as google.maps.OverlayView).getMap()
665
664
 
666
665
  const bounds = map !== null && 'getBounds' in map ? map.getBounds() : null
667
666
 
667
+ const zoom = map?.getZoom() || 0
668
668
  // Get our current map view bounds.
669
669
  // Create a new bounds object so we don't affect the map.
670
670
  //
671
671
  // See Comments 9 & 11 on Issue 3651 relating to this workaround for a Google Maps bug:
672
- const mapBounds =
673
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
674
- // @ts-ignore
675
- map.getZoom() > 3
672
+ const mapBounds = zoom > 3
676
673
  ? new google.maps.LatLngBounds(
677
674
  bounds?.getSouthWest(),
678
675
  bounds?.getNorthEast()
@@ -719,10 +716,10 @@ export class Clusterer extends google.maps.OverlayView {
719
716
  }
720
717
  }
721
718
 
722
- extend<A extends typeof ClusterIcon | typeof Clusterer>(obj1: A, obj2: typeof google.maps.OverlayView) {
723
- return function applyExtend(this: A, object: typeof google.maps.OverlayView) {
719
+ extend<A extends typeof ClusterIcon | typeof Clusterer>(obj1: A, obj2: typeof google.maps.OverlayView): A {
720
+ return function applyExtend(this: A, object: typeof google.maps.OverlayView): A {
724
721
  for (const property in object.prototype) {
725
- this.prototype.set(property, object.prototype.get(property))
722
+ (this.prototype as unknown as google.maps.OverlayView).set(property, object.prototype.get(property))
726
723
  }
727
724
 
728
725
  return this