Skip to content

Commit

Permalink
Adopted fix for angular universal support (#1747)
Browse files Browse the repository at this point in the history
Fixes #1052
  • Loading branch information
pertsenga authored and doom777 committed Nov 12, 2019
1 parent a1a17a6 commit 7e408e9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/core/directives/map.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, ElementRef, EventEmitter, Input, NgZone, OnChanges, OnDestroy, OnInit, Output, SimpleChanges } from '@angular/core';
import { isPlatformServer } from '@angular/common';
import { Component, ElementRef, EventEmitter, Inject, Input, NgZone, OnChanges, OnDestroy, OnInit, Output, PLATFORM_ID, SimpleChanges } from '@angular/core';
import { Subscription } from 'rxjs';

import { MouseEvent } from '../map-types';
Expand Down Expand Up @@ -378,11 +379,20 @@ export class AgmMap implements OnChanges, OnInit, OnDestroy {
*/
@Output() tilesLoaded: EventEmitter<void> = new EventEmitter<void>();

constructor(private _elem: ElementRef, private _mapsWrapper: GoogleMapsAPIWrapper, protected _fitBoundsService: FitBoundsService, private _zone: NgZone) {
}
constructor(
private _elem: ElementRef,
private _mapsWrapper: GoogleMapsAPIWrapper,
@Inject(PLATFORM_ID) private _platformId: Object,
protected _fitBoundsService: FitBoundsService,
private _zone: NgZone
) {}

/** @internal */
ngOnInit() {
if (isPlatformServer(this._platformId)) {
// The code is running on the server, do nothing
return;
}
// todo: this should be solved with a new component and a viewChild decorator
const container = this._elem.nativeElement.querySelector('.agm-map-container-inner');
this._initMapInstance(container);
Expand Down

0 comments on commit 7e408e9

Please sign in to comment.