Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug([google-map]): [README.MD example only produces grey rectangle, no map] #18965

Closed
eamon-otuathail opened this issue Apr 1, 2020 · 6 comments · Fixed by #18967, lingounet/testage#29 or michael-vasyliv/ngx-virtual-swiper#24
Assignees
Labels
P2 The issue is important to a large percentage of users, with a workaround

Comments

@eamon-otuathail
Copy link

Reproduction

The README for Google Maps contains code that produces just a grey map:
https://github.com/angular/components/blob/master/src/google-maps/README.md

Steps to reproduce:
Add the readme code to a brand new simple new demo project (ng new demo)

Expected Behavior

The map should be displayed correctly, without having to force a refresh.

Actual Behavior

A grey rectangle is displayed where the map should be.
No error messages are produced.
Note the README example did work correctly for Google Maps in Angular Components 9.0.

With Google-Maps in Angular Components 9.2, to get a map correctly displayed, one now needs to add this extra line to the demo .html file:
[mapTypeId]="mapTypeId"
And add this line to the demo .ts file:
mapTypeId: google.maps.MapTypeId;
and also implement AfterViewInit to force a redraw:
export class GoogleMapDemo implements AfterViewInit {
..
ngAfterViewInit(): void {
// Vary the map properties somehow to force a redraw
this.mapTypeId = google.maps.MapTypeId.ROADMAP;
}
}

Environment

  • Angular: 9.1.0
  • CDK/Material: 9.2.0
  • Browser(s): Chrome 83.0.4093.3
  • Operating System: Windows
@eamon-otuathail eamon-otuathail added the needs triage This issue needs to be triaged by the team label Apr 1, 2020
@TheLazyHatGuy
Copy link

Try installing @angular/google-maps@9.1.3

@crisbeto crisbeto self-assigned this Apr 1, 2020
@crisbeto crisbeto added has pr P2 The issue is important to a large percentage of users, with a workaround and removed needs triage This issue needs to be triaged by the team labels Apr 1, 2020
crisbeto added a commit to crisbeto/material2 that referenced this issue Apr 1, 2020
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 angular#18965.
@sebinbenjamin
Copy link

Try installing @angular/google-maps@9.1.3

Works ! Thanks

@enaukkarinen
Copy link

Try installing @angular/google-maps@9.1.3

Worked for me too. 9.2.0 seems broken.

mmalerba pushed a commit that referenced this issue Apr 7, 2020
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.
mmalerba pushed a commit that referenced this issue Apr 7, 2020
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.
@MrFurther
Copy link

MrFurther commented Apr 11, 2020

I still see the issue, even after having installed v9.1.3.
The map renders fine in local, but it will throw a grey rectangle in production. No error in console on load, just this when I try to zoom in/out in the grey box:

Uncaught TypeError: Cannot read property 'zoom' of null

I've tried:

-Setting different css
-Moving the setting of center from ngInit to AfterViewInit
-Checked API keys and permissions

@crisbeto
Copy link
Member

The fix that closed this issue hasn't been released yet.

mmalerba pushed a commit that referenced this issue Apr 14, 2020
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.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P2 The issue is important to a large percentage of users, with a workaround
Projects
None yet
6 participants