@react-google-maps/marker-clusterer 2.11.1 → 2.11.4
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 +149 -104
- package/dist/cjs.js.map +1 -1
- package/dist/cjs.min.js +1 -1
- package/dist/cjs.min.js.map +1 -1
- package/dist/esm.js +149 -104
- package/dist/esm.js.map +1 -1
- package/dist/esm.min.js +1 -1
- package/dist/esm.min.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/umd.js +149 -104
- package/dist/umd.js.map +1 -1
- package/dist/umd.min.js +1 -1
- package/dist/umd.min.js.map +1 -1
- package/package.json +2 -2
- package/src/Cluster.tsx +15 -2
- package/src/ClusterIcon.tsx +26 -11
- package/src/Clusterer.tsx +71 -20
package/src/Clusterer.tsx
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
* Supports up to 9007199254740991 (Number.MAX_SAFE_INTEGER) markers
|
|
16
16
|
* which is not a problem as max array length is 4294967296 (2**32)
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
function CALCULATOR(
|
|
19
19
|
markers: MarkerExtended[],
|
|
20
20
|
numStyles: number
|
|
21
21
|
): ClusterIconInfo {
|
|
@@ -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
|
|
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,9 +134,64 @@ export class Clusterer extends google.maps.OverlayView {
|
|
|
136
134
|
|
|
137
135
|
this.setupStyles()
|
|
138
136
|
|
|
139
|
-
this.addMarkers(optMarkers, true)
|
|
140
|
-
|
|
141
|
-
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
|
|
140
|
+
|
|
141
|
+
this.onZoomChanged = this.onZoomChanged.bind(this)
|
|
142
|
+
this.onIdle = this.onIdle.bind(this)
|
|
143
|
+
this.onAdd = this.onAdd.bind(this)
|
|
144
|
+
this.onRemove = this.onRemove.bind(this)
|
|
145
|
+
this.draw = this.draw.bind(this)
|
|
146
|
+
this.setupStyles = this.setupStyles.bind(this)
|
|
147
|
+
this.fitMapToMarkers = this.fitMapToMarkers.bind(this)
|
|
148
|
+
this.getGridSize = this.getGridSize.bind(this)
|
|
149
|
+
this.setGridSize = this.setGridSize.bind(this)
|
|
150
|
+
this.getMinimumClusterSize = this.getMinimumClusterSize.bind(this)
|
|
151
|
+
this.setMinimumClusterSize = this.setMinimumClusterSize.bind(this)
|
|
152
|
+
this.getMaxZoom = this.getMaxZoom.bind(this)
|
|
153
|
+
this.setMaxZoom = this.setMaxZoom.bind(this)
|
|
154
|
+
this.getStyles = this.getStyles.bind(this)
|
|
155
|
+
this.setStyles = this.setStyles.bind(this)
|
|
156
|
+
this.getTitle = this.getTitle.bind(this)
|
|
157
|
+
this.setTitle = this.setTitle.bind(this)
|
|
158
|
+
this.getZoomOnClick = this.getZoomOnClick.bind(this)
|
|
159
|
+
this.setZoomOnClick = this.setZoomOnClick.bind(this)
|
|
160
|
+
this.getAverageCenter = this.getAverageCenter.bind(this)
|
|
161
|
+
this.setAverageCenter = this.setAverageCenter.bind(this)
|
|
162
|
+
this.getIgnoreHidden = this.getIgnoreHidden.bind(this)
|
|
163
|
+
this.setIgnoreHidden = this.setIgnoreHidden.bind(this)
|
|
164
|
+
this.getEnableRetinaIcons = this.getEnableRetinaIcons.bind(this)
|
|
165
|
+
this.setEnableRetinaIcons = this.setEnableRetinaIcons.bind(this)
|
|
166
|
+
this.getImageExtension = this.getImageExtension.bind(this)
|
|
167
|
+
this.setImageExtension = this.setImageExtension.bind(this)
|
|
168
|
+
this.getImagePath = this.getImagePath.bind(this)
|
|
169
|
+
this.setImagePath = this.setImagePath.bind(this)
|
|
170
|
+
this.getImageSizes = this.getImageSizes.bind(this)
|
|
171
|
+
this.setImageSizes = this.setImageSizes.bind(this)
|
|
172
|
+
this.getCalculator = this.getCalculator.bind(this)
|
|
173
|
+
this.setCalculator = this.setCalculator.bind(this)
|
|
174
|
+
this.getBatchSizeIE = this.getBatchSizeIE.bind(this)
|
|
175
|
+
this.setBatchSizeIE = this.setBatchSizeIE.bind(this)
|
|
176
|
+
this.getClusterClass = this.getClusterClass.bind(this)
|
|
177
|
+
this.setClusterClass = this.setClusterClass.bind(this)
|
|
178
|
+
this.getMarkers = this.getMarkers.bind(this)
|
|
179
|
+
this.getTotalMarkers = this.getTotalMarkers.bind(this)
|
|
180
|
+
this.getClusters = this.getClusters.bind(this)
|
|
181
|
+
this.getTotalClusters = this.getTotalClusters.bind(this)
|
|
182
|
+
this.addMarker = this.addMarker.bind(this)
|
|
183
|
+
this.addMarkers = this.addMarkers.bind(this)
|
|
184
|
+
this.pushMarkerTo = this.pushMarkerTo.bind(this)
|
|
185
|
+
this.removeMarker = this.removeMarker.bind(this)
|
|
186
|
+
this.removeMarkers = this.removeMarkers.bind(this)
|
|
187
|
+
this.clearMarkers = this.clearMarkers.bind(this)
|
|
188
|
+
this.repaint = this.repaint.bind(this)
|
|
189
|
+
this.getExtendedBounds = this.getExtendedBounds.bind(this)
|
|
190
|
+
this.redraw = this.redraw.bind(this)
|
|
191
|
+
this.resetViewport = this.resetViewport.bind(this)
|
|
192
|
+
this.addToClosestCluster = this.addToClosestCluster.bind(this)
|
|
193
|
+
this.createClusters = this.createClusters.bind(this)
|
|
194
|
+
this.extend = this.extend.bind(this)
|
|
142
195
|
}
|
|
143
196
|
|
|
144
197
|
onZoomChanged() {
|
|
@@ -150,9 +203,8 @@ export class Clusterer extends google.maps.OverlayView {
|
|
|
150
203
|
// event is triggered so the cluster markers that have been removed
|
|
151
204
|
// do not get redrawn. Same goes for a zoom in at maxZoom.
|
|
152
205
|
if (
|
|
153
|
-
this.getMap()?.getZoom() === (this.get('minZoom') || 0) ||
|
|
154
|
-
|
|
155
|
-
this.getMap()?.getZoom() === this.get('maxZoom')
|
|
206
|
+
(this as unknown as google.maps.OverlayView).getMap()?.getZoom() === ((this as unknown as google.maps.OverlayView).get('minZoom') || 0) ||
|
|
207
|
+
(this as unknown as google.maps.OverlayView).getMap()?.getZoom() === (this as unknown as google.maps.OverlayView).get('maxZoom')
|
|
156
208
|
) {
|
|
157
209
|
google.maps.event.trigger(this, 'idle')
|
|
158
210
|
}
|
|
@@ -163,7 +215,7 @@ export class Clusterer extends google.maps.OverlayView {
|
|
|
163
215
|
}
|
|
164
216
|
|
|
165
217
|
onAdd() {
|
|
166
|
-
const map = this.getMap()
|
|
218
|
+
const map = (this as unknown as google.maps.OverlayView).getMap()
|
|
167
219
|
|
|
168
220
|
this.activeMap = map
|
|
169
221
|
|
|
@@ -215,8 +267,7 @@ export class Clusterer extends google.maps.OverlayView {
|
|
|
215
267
|
this.ready = false
|
|
216
268
|
}
|
|
217
269
|
|
|
218
|
-
|
|
219
|
-
draw() {}
|
|
270
|
+
draw() { return }
|
|
220
271
|
|
|
221
272
|
setupStyles() {
|
|
222
273
|
if (this.styles.length > 0) {
|
|
@@ -225,7 +276,7 @@ export class Clusterer extends google.maps.OverlayView {
|
|
|
225
276
|
|
|
226
277
|
for (let i = 0; i < this.imageSizes.length; i++) {
|
|
227
278
|
this.styles.push({
|
|
228
|
-
url: this.imagePath + (i + 1)
|
|
279
|
+
url: `${this.imagePath + (i + 1)}.${this.imageExtension}`,
|
|
229
280
|
height: this.imageSizes[i],
|
|
230
281
|
width: this.imageSizes[i],
|
|
231
282
|
})
|
|
@@ -245,7 +296,7 @@ export class Clusterer extends google.maps.OverlayView {
|
|
|
245
296
|
}
|
|
246
297
|
}
|
|
247
298
|
|
|
248
|
-
const map = this.getMap()
|
|
299
|
+
const map = (this as unknown as google.maps.OverlayView).getMap()
|
|
249
300
|
|
|
250
301
|
if (map !== null && 'fitBounds' in map) {
|
|
251
302
|
map.fitBounds(bounds)
|
|
@@ -502,7 +553,7 @@ export class Clusterer extends google.maps.OverlayView {
|
|
|
502
553
|
}
|
|
503
554
|
|
|
504
555
|
getExtendedBounds(bounds: google.maps.LatLngBounds): google.maps.LatLngBounds {
|
|
505
|
-
const projection = this.getProjection()
|
|
556
|
+
const projection = (this as unknown as google.maps.OverlayView).getProjection()
|
|
506
557
|
|
|
507
558
|
// Convert the points to pixels and the extend out by the grid size.
|
|
508
559
|
const trPix = projection.fromLatLngToDivPixel(
|
|
@@ -663,7 +714,7 @@ export class Clusterer extends google.maps.OverlayView {
|
|
|
663
714
|
}
|
|
664
715
|
}
|
|
665
716
|
|
|
666
|
-
const map = this.getMap()
|
|
717
|
+
const map = (this as unknown as google.maps.OverlayView).getMap()
|
|
667
718
|
|
|
668
719
|
const bounds = map !== null && 'getBounds' in map ? map.getBounds() : null
|
|
669
720
|
|
|
@@ -719,10 +770,10 @@ export class Clusterer extends google.maps.OverlayView {
|
|
|
719
770
|
}
|
|
720
771
|
}
|
|
721
772
|
|
|
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) {
|
|
773
|
+
extend<A extends typeof ClusterIcon | typeof Clusterer>(obj1: A, obj2: typeof google.maps.OverlayView): A {
|
|
774
|
+
return function applyExtend(this: A, object: typeof google.maps.OverlayView): A {
|
|
724
775
|
for (const property in object.prototype) {
|
|
725
|
-
this.prototype.set(property, object.prototype.get(property))
|
|
776
|
+
(this.prototype as unknown as google.maps.OverlayView).set(property, object.prototype.get(property))
|
|
726
777
|
}
|
|
727
778
|
|
|
728
779
|
return this
|