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): fitBounds need to run in setTimeout to apply #24703

Open
1 task
christophe-mailfert opened this issue Mar 30, 2022 · 3 comments
Open
1 task
Labels
needs: clarification The issue does not contain enough information for the team to determine if it is a real bug P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@christophe-mailfert
Copy link

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Our app use a lot of GoogleMap and duno why the first loading of the map works correctly but all other with the navigation fail to fitBounds.
The only why i found to fix it is to wrap the fitbounds with a setTimeout.

Reproduction

Steps to reproduce:

  1. https://stackblitz.com/edit/components-issue-wtbvby?file=src%2Fapp%2Fexample-component.ts
  2. Without the setTimeout nothing appends
  3. With the map update the center

Expected Behavior

fitbounds without a setTImeout

Actual Behavior

Need a setTimeout to fitBounds

Environment

  • Angular: 13
  • CDK/Material: 13
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): MacOS
@christophe-mailfert christophe-mailfert added the needs triage This issue needs to be triaged by the team label Mar 30, 2022
@andrewseguin
Copy link
Contributor

The stackblitz is not working - it shows an empty page

@andrewseguin andrewseguin added needs: clarification The issue does not contain enough information for the team to determine if it is a real bug and removed needs triage This issue needs to be triaged by the team labels Apr 27, 2022
@mloffer
Copy link

mloffer commented May 11, 2023

This is still a problem.

  • @ViewChild(GoogleMap) is undefined inside ngAfterViewInit.
    • Still undefined if you reference it inside setTimeout.
  • @ViewChild(GoogleMap) is undefined inside of GoogleMap.mapInitialized
    • Finally available if you reference it inside setTimeout.

@andrewseguin andrewseguin added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Jun 1, 2023
@Ritin
Copy link

Ritin commented Jan 9, 2024

facing same issue
@angular/core@17.0.8
@angular/google-maps@17.0.4

@ViewChild(MapPolygon) daPolygon: MapPolygon;
@ViewChild('map') daGMap!: GoogleMap;
GoogleMap and MapPolygon are undefined inside onMapInitialized()
wanted to add that
it works inside onMapClick() without the need for setTimeout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: clarification The issue does not contain enough information for the team to determine if it is a real bug P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

4 participants