@@ -244,7 +244,9 @@ export class DeprecatedMapMarkerClusterer
244244 return new MarkerClusterer ( map , [ ] , this . _combineOptions ( ) ) ;
245245 } ) ;
246246
247- this . _assertInitialized ( ) ;
247+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
248+ assertInitialized ( this ) ;
249+ }
248250 this . _eventManager . setTarget ( this . markerClusterer ) ;
249251 this . markerClustererInitialized . emit ( this . markerClusterer ) ;
250252 } ) ;
@@ -352,103 +354,143 @@ export class DeprecatedMapMarkerClusterer
352354 }
353355
354356 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 ) ;
357361 }
358362
359363 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 ( ) ;
362368 }
363369
364370 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 ( ) ;
367375 }
368376
369377 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 ( ) ;
372382 }
373383
374384 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 ( ) ;
377389 }
378390
379391 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 ( ) ;
382396 }
383397
384398 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 ( ) ;
387403 }
388404
389405 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 ( ) ;
392410 }
393411
394412 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 ( ) ;
397417 }
398418
399419 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 ( ) ;
402424 }
403425
404426 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 ( ) ;
407431 }
408432
409433 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 ( ) ;
412438 }
413439
414440 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 ( ) ;
417445 }
418446
419447 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 ( ) ;
422452 }
423453
424454 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 ( ) ;
427459 }
428460
429461 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 ( ) ;
432466 }
433467
434468 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 ( ) ;
437473 }
438474
439475 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 ( ) ;
442480 }
443481
444482 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 ( ) ;
447487 }
448488
449489 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 ( ) ;
452494 }
453495
454496 private _combineOptions ( ) : MarkerClustererOptions {
@@ -477,7 +519,9 @@ export class DeprecatedMapMarkerClusterer
477519 }
478520
479521 private _watchForMarkerChanges ( ) {
480- this . _assertInitialized ( ) ;
522+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
523+ assertInitialized ( this ) ;
524+ }
481525
482526 this . _ngZone . runOutsideAngular ( ( ) => {
483527 this . _getInternalMarkers ( this . _markers ) . then ( markers => {
@@ -486,14 +530,16 @@ export class DeprecatedMapMarkerClusterer
486530 this . _currentMarkers . add ( marker ) ;
487531 initialMarkers . push ( marker ) ;
488532 }
489- this . markerClusterer . addMarkers ( initialMarkers ) ;
533+ this . markerClusterer ! . addMarkers ( initialMarkers ) ;
490534 } ) ;
491535 } ) ;
492536
493537 this . _markers . changes
494538 . pipe ( takeUntil ( this . _destroy ) )
495539 . subscribe ( ( markerComponents : MapMarker [ ] ) => {
496- this . _assertInitialized ( ) ;
540+ if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
541+ assertInitialized ( this ) ;
542+ }
497543 this . _ngZone . runOutsideAngular ( ( ) => {
498544 this . _getInternalMarkers ( markerComponents ) . then ( markers => {
499545 const newMarkers = new Set ( markers ) ;
@@ -510,9 +556,9 @@ export class DeprecatedMapMarkerClusterer
510556 markersToRemove . push ( marker ) ;
511557 }
512558 }
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 ( ) ;
516562 for ( const marker of markersToRemove ) {
517563 this . _currentMarkers . delete ( marker ) ;
518564 }
@@ -526,15 +572,13 @@ export class DeprecatedMapMarkerClusterer
526572 ) : Promise < google . maps . Marker [ ] > {
527573 return Promise . all ( markers . map ( markerComponent => markerComponent . _resolveMarker ( ) ) ) ;
528574 }
575+ }
529576
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+ ) ;
539583 }
540584}
0 commit comments