@@ -244,7 +244,9 @@ export class DeprecatedMapMarkerClusterer
244
244
return new MarkerClusterer ( map , [ ] , this . _combineOptions ( ) ) ;
245
245
} ) ;
246
246
247
- this . _assertInitialized ( ) ;
247
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
248
+ assertInitialized ( this ) ;
249
+ }
248
250
this . _eventManager . setTarget ( this . markerClusterer ) ;
249
251
this . markerClustererInitialized . emit ( this . markerClusterer ) ;
250
252
} ) ;
@@ -352,103 +354,143 @@ export class DeprecatedMapMarkerClusterer
352
354
}
353
355
354
356
fitMapToMarkers ( padding : number | google . maps . Padding ) {
355
- this . _assertInitialized ( ) ;
356
- this . markerClusterer . fitMapToMarkers ( padding ) ;
357
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
358
+ assertInitialized ( this ) ;
359
+ }
360
+ this . markerClusterer ! . fitMapToMarkers ( padding ) ;
357
361
}
358
362
359
363
getAverageCenter ( ) : boolean {
360
- this . _assertInitialized ( ) ;
361
- return this . markerClusterer . getAverageCenter ( ) ;
364
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
365
+ assertInitialized ( this ) ;
366
+ }
367
+ return this . markerClusterer ! . getAverageCenter ( ) ;
362
368
}
363
369
364
370
getBatchSizeIE ( ) : number {
365
- this . _assertInitialized ( ) ;
366
- return this . markerClusterer . getBatchSizeIE ( ) ;
371
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
372
+ assertInitialized ( this ) ;
373
+ }
374
+ return this . markerClusterer ! . getBatchSizeIE ( ) ;
367
375
}
368
376
369
377
getCalculator ( ) : Calculator {
370
- this . _assertInitialized ( ) ;
371
- return this . markerClusterer . getCalculator ( ) ;
378
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
379
+ assertInitialized ( this ) ;
380
+ }
381
+ return this . markerClusterer ! . getCalculator ( ) ;
372
382
}
373
383
374
384
getClusterClass ( ) : string {
375
- this . _assertInitialized ( ) ;
376
- return this . markerClusterer . getClusterClass ( ) ;
385
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
386
+ assertInitialized ( this ) ;
387
+ }
388
+ return this . markerClusterer ! . getClusterClass ( ) ;
377
389
}
378
390
379
391
getClusters ( ) : Cluster [ ] {
380
- this . _assertInitialized ( ) ;
381
- return this . markerClusterer . getClusters ( ) ;
392
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
393
+ assertInitialized ( this ) ;
394
+ }
395
+ return this . markerClusterer ! . getClusters ( ) ;
382
396
}
383
397
384
398
getEnableRetinaIcons ( ) : boolean {
385
- this . _assertInitialized ( ) ;
386
- return this . markerClusterer . getEnableRetinaIcons ( ) ;
399
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
400
+ assertInitialized ( this ) ;
401
+ }
402
+ return this . markerClusterer ! . getEnableRetinaIcons ( ) ;
387
403
}
388
404
389
405
getGridSize ( ) : number {
390
- this . _assertInitialized ( ) ;
391
- return this . markerClusterer . getGridSize ( ) ;
406
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
407
+ assertInitialized ( this ) ;
408
+ }
409
+ return this . markerClusterer ! . getGridSize ( ) ;
392
410
}
393
411
394
412
getIgnoreHidden ( ) : boolean {
395
- this . _assertInitialized ( ) ;
396
- return this . markerClusterer . getIgnoreHidden ( ) ;
413
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
414
+ assertInitialized ( this ) ;
415
+ }
416
+ return this . markerClusterer ! . getIgnoreHidden ( ) ;
397
417
}
398
418
399
419
getImageExtension ( ) : string {
400
- this . _assertInitialized ( ) ;
401
- return this . markerClusterer . getImageExtension ( ) ;
420
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
421
+ assertInitialized ( this ) ;
422
+ }
423
+ return this . markerClusterer ! . getImageExtension ( ) ;
402
424
}
403
425
404
426
getImagePath ( ) : string {
405
- this . _assertInitialized ( ) ;
406
- return this . markerClusterer . getImagePath ( ) ;
427
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
428
+ assertInitialized ( this ) ;
429
+ }
430
+ return this . markerClusterer ! . getImagePath ( ) ;
407
431
}
408
432
409
433
getImageSizes ( ) : number [ ] {
410
- this . _assertInitialized ( ) ;
411
- return this . markerClusterer . getImageSizes ( ) ;
434
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
435
+ assertInitialized ( this ) ;
436
+ }
437
+ return this . markerClusterer ! . getImageSizes ( ) ;
412
438
}
413
439
414
440
getMaxZoom ( ) : number {
415
- this . _assertInitialized ( ) ;
416
- return this . markerClusterer . getMaxZoom ( ) ;
441
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
442
+ assertInitialized ( this ) ;
443
+ }
444
+ return this . markerClusterer ! . getMaxZoom ( ) ;
417
445
}
418
446
419
447
getMinimumClusterSize ( ) : number {
420
- this . _assertInitialized ( ) ;
421
- return this . markerClusterer . getMinimumClusterSize ( ) ;
448
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
449
+ assertInitialized ( this ) ;
450
+ }
451
+ return this . markerClusterer ! . getMinimumClusterSize ( ) ;
422
452
}
423
453
424
454
getStyles ( ) : ClusterIconStyle [ ] {
425
- this . _assertInitialized ( ) ;
426
- return this . markerClusterer . getStyles ( ) ;
455
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
456
+ assertInitialized ( this ) ;
457
+ }
458
+ return this . markerClusterer ! . getStyles ( ) ;
427
459
}
428
460
429
461
getTitle ( ) : string {
430
- this . _assertInitialized ( ) ;
431
- return this . markerClusterer . getTitle ( ) ;
462
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
463
+ assertInitialized ( this ) ;
464
+ }
465
+ return this . markerClusterer ! . getTitle ( ) ;
432
466
}
433
467
434
468
getTotalClusters ( ) : number {
435
- this . _assertInitialized ( ) ;
436
- return this . markerClusterer . getTotalClusters ( ) ;
469
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
470
+ assertInitialized ( this ) ;
471
+ }
472
+ return this . markerClusterer ! . getTotalClusters ( ) ;
437
473
}
438
474
439
475
getTotalMarkers ( ) : number {
440
- this . _assertInitialized ( ) ;
441
- return this . markerClusterer . getTotalMarkers ( ) ;
476
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
477
+ assertInitialized ( this ) ;
478
+ }
479
+ return this . markerClusterer ! . getTotalMarkers ( ) ;
442
480
}
443
481
444
482
getZIndex ( ) : number {
445
- this . _assertInitialized ( ) ;
446
- return this . markerClusterer . getZIndex ( ) ;
483
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
484
+ assertInitialized ( this ) ;
485
+ }
486
+ return this . markerClusterer ! . getZIndex ( ) ;
447
487
}
448
488
449
489
getZoomOnClick ( ) : boolean {
450
- this . _assertInitialized ( ) ;
451
- return this . markerClusterer . getZoomOnClick ( ) ;
490
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
491
+ assertInitialized ( this ) ;
492
+ }
493
+ return this . markerClusterer ! . getZoomOnClick ( ) ;
452
494
}
453
495
454
496
private _combineOptions ( ) : MarkerClustererOptions {
@@ -477,7 +519,9 @@ export class DeprecatedMapMarkerClusterer
477
519
}
478
520
479
521
private _watchForMarkerChanges ( ) {
480
- this . _assertInitialized ( ) ;
522
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
523
+ assertInitialized ( this ) ;
524
+ }
481
525
482
526
this . _ngZone . runOutsideAngular ( ( ) => {
483
527
this . _getInternalMarkers ( this . _markers ) . then ( markers => {
@@ -486,14 +530,16 @@ export class DeprecatedMapMarkerClusterer
486
530
this . _currentMarkers . add ( marker ) ;
487
531
initialMarkers . push ( marker ) ;
488
532
}
489
- this . markerClusterer . addMarkers ( initialMarkers ) ;
533
+ this . markerClusterer ! . addMarkers ( initialMarkers ) ;
490
534
} ) ;
491
535
} ) ;
492
536
493
537
this . _markers . changes
494
538
. pipe ( takeUntil ( this . _destroy ) )
495
539
. subscribe ( ( markerComponents : MapMarker [ ] ) => {
496
- this . _assertInitialized ( ) ;
540
+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
541
+ assertInitialized ( this ) ;
542
+ }
497
543
this . _ngZone . runOutsideAngular ( ( ) => {
498
544
this . _getInternalMarkers ( markerComponents ) . then ( markers => {
499
545
const newMarkers = new Set ( markers ) ;
@@ -510,9 +556,9 @@ export class DeprecatedMapMarkerClusterer
510
556
markersToRemove . push ( marker ) ;
511
557
}
512
558
}
513
- this . markerClusterer . addMarkers ( markersToAdd , true ) ;
514
- this . markerClusterer . removeMarkers ( markersToRemove , true ) ;
515
- this . markerClusterer . repaint ( ) ;
559
+ this . markerClusterer ! . addMarkers ( markersToAdd , true ) ;
560
+ this . markerClusterer ! . removeMarkers ( markersToRemove , true ) ;
561
+ this . markerClusterer ! . repaint ( ) ;
516
562
for ( const marker of markersToRemove ) {
517
563
this . _currentMarkers . delete ( marker ) ;
518
564
}
@@ -526,15 +572,13 @@ export class DeprecatedMapMarkerClusterer
526
572
) : Promise < google . maps . Marker [ ] > {
527
573
return Promise . all ( markers . map ( markerComponent => markerComponent . _resolveMarker ( ) ) ) ;
528
574
}
575
+ }
529
576
530
- private _assertInitialized ( ) : asserts this is { markerClusterer : MarkerClustererInstance } {
531
- if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
532
- if ( ! this . markerClusterer ) {
533
- throw Error (
534
- 'Cannot interact with a MarkerClusterer before it has been initialized. ' +
535
- 'Please wait for the MarkerClusterer to load before trying to interact with it.' ,
536
- ) ;
537
- }
538
- }
577
+ function assertInitialized ( ctx : DeprecatedMapMarkerClusterer ) {
578
+ if ( ! ctx . markerClusterer ) {
579
+ throw Error (
580
+ 'Cannot interact with a MarkerClusterer before it has been initialized. ' +
581
+ 'Please wait for the MarkerClusterer to load before trying to interact with it.' ,
582
+ ) ;
539
583
}
540
584
}
0 commit comments