Skip to content

Commit 23161d7

Browse files
authored
fix(google-maps): not rendering until mapTypeId is set (#18967)
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.
1 parent 029e363 commit 23161d7

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/google-maps/google-map/google-map.spec.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ describe('GoogleMap', () => {
7474
const container = fixture.debugElement.query(By.css('div'))!;
7575
expect(container.nativeElement.style.height).toBe(DEFAULT_HEIGHT);
7676
expect(container.nativeElement.style.width).toBe(DEFAULT_WIDTH);
77-
expect(mapConstructorSpy).toHaveBeenCalledWith(container.nativeElement, DEFAULT_OPTIONS);
77+
expect(mapConstructorSpy).toHaveBeenCalledWith(container.nativeElement, {
78+
...DEFAULT_OPTIONS,
79+
mapTypeId: undefined
80+
});
7881
});
7982

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

94100
fixture.componentInstance.height = '650px';
95101
fixture.componentInstance.width = '350px';

src/google-maps/google-map/google-map.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ export interface UpdatedGoogleMap extends google.maps.Map {
4545
/** default options set to the Googleplex */
4646
export const DEFAULT_OPTIONS: google.maps.MapOptions = {
4747
center: {lat: 37.421995, lng: -122.084092},
48-
zoom: 17,
49-
mapTypeId: undefined
48+
zoom: 17
5049
};
5150

5251
/** Arbitrary default height for the map element */

0 commit comments

Comments
 (0)