MCPcopy Create free account
hub / github.com/angular/components / ngOnInit

Method ngOnInit

src/google-maps/google-map/google-map.ts:304–323  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

302 }
303
304 ngOnInit() {
305 // It should be a noop during server-side rendering.
306 if (this._isBrowser) {
307 this._mapEl = this._elementRef.nativeElement.querySelector('.map-container')!;
308 this._setSize();
309
310 // Create the object outside the zone so its events don't trigger change detection.
311 // We'll bring it back in inside the `MapEventManager` only for the events that the
312 // user has subscribed to.
313 if (google.maps.Map) {
314 this._initialize(google.maps.Map);
315 } else {
316 this._ngZone.runOutsideAngular(() => {
317 google.maps
318 .importLibrary('maps')
319 .then(lib => this._initialize((lib as google.maps.MapsLibrary).Map));
320 });
321 }
322 }
323 }
324
325 private _initialize(mapConstructor: typeof google.maps.Map) {
326 this._ngZone.runOutsideAngular(() => {

Callers

nothing calls this directly

Calls 2

_setSizeMethod · 0.95
_initializeMethod · 0.95

Tested by

no test coverage detected