@@ -159,29 +159,32 @@ export class MapCircle implements OnInit, OnDestroy {
159
159
constructor ( private readonly _map : GoogleMap , private readonly _ngZone : NgZone ) { }
160
160
161
161
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 ) ;
170
172
} ) ;
171
- this . circle . setMap ( this . _map . _googleMap ) ;
172
- this . _eventManager . setTarget ( this . circle ) ;
173
- } ) ;
174
173
175
- this . _watchForOptionsChanges ( ) ;
176
- this . _watchForCenterChanges ( ) ;
177
- this . _watchForRadiusChanges ( ) ;
174
+ this . _watchForOptionsChanges ( ) ;
175
+ this . _watchForCenterChanges ( ) ;
176
+ this . _watchForRadiusChanges ( ) ;
177
+ }
178
178
}
179
179
180
180
ngOnDestroy ( ) {
181
181
this . _eventManager . destroy ( ) ;
182
182
this . _destroyed . next ( ) ;
183
183
this . _destroyed . complete ( ) ;
184
- this . circle . setMap ( null ) ;
184
+
185
+ if ( this . circle ) {
186
+ this . circle . setMap ( null ) ;
187
+ }
185
188
}
186
189
187
190
/**
0 commit comments