Skip to content

Commit

Permalink
fix(google-maps): not rendering until mapTypeId is set (#18967)
Browse files Browse the repository at this point in the history
In 2a6aae1 I added the ability to set the `mapTypeId` and after I was done with it and ran the unit tests, I added a default of `undefined` to the `DEFAULT_OPTIONS` so the tests didn't have to be updated. It looks like having the `undefined` in the defaults causes Google Maps not to render anything in the map until the map type changes. These changes remove the default value and update the tests instead.

Fixes #18965.
  • Loading branch information
crisbeto authored and mmalerba committed Apr 14, 2020
1 parent 8cb51b2 commit 977c605
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/google-maps/google-map/google-map.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ describe('GoogleMap', () => {
const container = fixture.debugElement.query(By.css('div'))!;
expect(container.nativeElement.style.height).toBe(DEFAULT_HEIGHT);
expect(container.nativeElement.style.width).toBe(DEFAULT_WIDTH);
expect(mapConstructorSpy).toHaveBeenCalledWith(container.nativeElement, DEFAULT_OPTIONS);
expect(mapConstructorSpy).toHaveBeenCalledWith(container.nativeElement, {
...DEFAULT_OPTIONS,
mapTypeId: undefined
});
});

it('sets height and width of the map', () => {
Expand All @@ -89,7 +92,10 @@ describe('GoogleMap', () => {
const container = fixture.debugElement.query(By.css('div'))!;
expect(container.nativeElement.style.height).toBe('750px');
expect(container.nativeElement.style.width).toBe('400px');
expect(mapConstructorSpy).toHaveBeenCalledWith(container.nativeElement, DEFAULT_OPTIONS);
expect(mapConstructorSpy).toHaveBeenCalledWith(container.nativeElement, {
...DEFAULT_OPTIONS,
mapTypeId: undefined
});

fixture.componentInstance.height = '650px';
fixture.componentInstance.width = '350px';
Expand Down
3 changes: 1 addition & 2 deletions src/google-maps/google-map/google-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ export interface UpdatedGoogleMap extends google.maps.Map {
/** default options set to the Googleplex */
export const DEFAULT_OPTIONS: google.maps.MapOptions = {
center: {lat: 37.421995, lng: -122.084092},
zoom: 17,
mapTypeId: undefined
zoom: 17
};

/** Arbitrary default height for the map element */
Expand Down

0 comments on commit 977c605

Please sign in to comment.