From 984d60bf901c33c82e513471c3706dcc65a755a8 Mon Sep 17 00:00:00 2001 From: crisbeto Date: Wed, 1 Apr 2020 19:46:26 +0200 Subject: [PATCH] fix(google-maps): not rendering until mapTypeId is set In 2a6aae179a436886395cc8ecc631f7c7be4dff24 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. --- src/google-maps/google-map/google-map.spec.ts | 10 ++++++++-- src/google-maps/google-map/google-map.ts | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/google-maps/google-map/google-map.spec.ts b/src/google-maps/google-map/google-map.spec.ts index e79734fea201..1370413852bc 100644 --- a/src/google-maps/google-map/google-map.spec.ts +++ b/src/google-maps/google-map/google-map.spec.ts @@ -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', () => { @@ -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'; diff --git a/src/google-maps/google-map/google-map.ts b/src/google-maps/google-map/google-map.ts index 81c3a7a2a14d..26ba8c2da668 100644 --- a/src/google-maps/google-map/google-map.ts +++ b/src/google-maps/google-map/google-map.ts @@ -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 */