@@ -159,29 +159,32 @@ export class MapCircle implements OnInit, OnDestroy {
159159 constructor ( private readonly _map : GoogleMap , private readonly _ngZone : NgZone ) { }
160160
161161 ngOnInit ( ) {
162- const combinedOptionsChanges = this . _combineOptions ( ) ;
163-
164- combinedOptionsChanges . pipe ( take ( 1 ) ) . subscribe ( options => {
165- // Create the object outside the zone so its events don't trigger change detection.
166- // We'll bring it back in inside the `MapEventManager` only for the events that the
167- // user has subscribed to.
168- this . _ngZone . runOutsideAngular ( ( ) => {
169- this . circle = new google . maps . Circle ( options ) ;
162+ if ( this . _map . _isBrowser ) {
163+ this . _combineOptions ( ) . pipe ( take ( 1 ) ) . subscribe ( options => {
164+ // Create the object outside the zone so its events don't trigger change detection.
165+ // We'll bring it back in inside the `MapEventManager` only for the events that the
166+ // user has subscribed to.
167+ this . _ngZone . runOutsideAngular ( ( ) => {
168+ this . circle = new google . maps . Circle ( options ) ;
169+ } ) ;
170+ this . circle . setMap ( this . _map . _googleMap ) ;
171+ this . _eventManager . setTarget ( this . circle ) ;
170172 } ) ;
171- this . circle . setMap ( this . _map . _googleMap ) ;
172- this . _eventManager . setTarget ( this . circle ) ;
173- } ) ;
174173
175- this . _watchForOptionsChanges ( ) ;
176- this . _watchForCenterChanges ( ) ;
177- this . _watchForRadiusChanges ( ) ;
174+ this . _watchForOptionsChanges ( ) ;
175+ this . _watchForCenterChanges ( ) ;
176+ this . _watchForRadiusChanges ( ) ;
177+ }
178178 }
179179
180180 ngOnDestroy ( ) {
181181 this . _eventManager . destroy ( ) ;
182182 this . _destroyed . next ( ) ;
183183 this . _destroyed . complete ( ) ;
184- this . circle . setMap ( null ) ;
184+
185+ if ( this . circle ) {
186+ this . circle . setMap ( null ) ;
187+ }
185188 }
186189
187190 /**
0 commit comments