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

ERROR Error: google is not defined when using fitBounds #1586

Closed
alexdabast opened this issue Jan 30, 2019 · 9 comments · Fixed by #1652
Closed

ERROR Error: google is not defined when using fitBounds #1586

alexdabast opened this issue Jan 30, 2019 · 9 comments · Fixed by #1652

Comments

@alexdabast
Copy link

Issue description
It's not possible to use fitBounds attribute with LatLngBoundsLiteral object only boolean.
I discover this only on 1.0.0-beta.5

Steps to reproduce and a minimal demo of the problem
Very easy to reproduce https://stackblitz.com/edit/agm-fitbounds-issue

Current behavior
Using a LatLngBoundsLiteral object as fitBounds lead to an error

Expected/desired behavior
We should be able to set a LatLngBoundsLiteral object as fitBounds

angular2 & angular-google-maps version
angular 6.0.0
agm/core 1.0.0-beta.5

Other information

@bramvanoploo
Copy link

I can confirm this problem

@IsaacSomething
Copy link
Contributor

IsaacSomething commented Feb 23, 2019

@agm/core/directives/map.js

 /**
  * Sets the viewport to contain the given bounds.
  * If this option to `true`, the bounds get automatically computed from 
  * all elements that use the {@link AgmFitBounds} directive.
  */
  this.fitBounds = false;

I wanted to see if the AgmFitBounds directive would solve the issue but the website is a bit buggered, i havn't used the fitbounds directive so im not sure, but it is missing from the stackblitz example

@alexdabast
Copy link
Author

@agm/core/directives/map.js

 /**
  * Sets the viewport to contain the given bounds.
  * If this option to `true`, the bounds get automatically computed from 
  * all elements that use the {@link AgmFitBounds} directive.
  */
  this.fitBounds = false;

I wanted to see if the AgmFitBounds directive would solve the issue but the website is a bit buggered, i havn't used the fitbounds directive so im not sure, but it is missing from the stackblitz example

If I'm not mistaken AgmFitBounds do not work on polylines only on markers

@PavleO
Copy link
Contributor

PavleO commented Feb 27, 2019

I had similar issue and did this:
in @agm/core/directives/map.js I replaced line 337 (it is line 478 in map.ts) with:
if (this._isLatLngBoundsLiteral(bounds) && typeof google !== 'undefined' && google && google.maps && google.maps.LatLngBounds()) {

and it worked after that.
Can you try this and confirm if this works for you too.

@stale
Copy link

stale bot commented May 28, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 28, 2019
@MKahmen
Copy link

MKahmen commented May 30, 2019

in @agm/core/directives/map.js I replaced line 337 (it is line 478 in map.ts) with:
if (this._isLatLngBoundsLiteral(bounds) && typeof google !== 'undefined' && google && google.maps && google.maps.LatLngBounds()) {

@PavleO I can confirm that it indeed fixes the bug. you saved me because I updated to Angular 7. Thanks!
I am wondering what's going on in this project... Is there a way to get this fix in the official npm?

@stale stale bot removed the stale label May 30, 2019
@alexdabast
Copy link
Author

Yes an official fix would be nice ...

@PavleO
Copy link
Contributor

PavleO commented May 31, 2019

Hi @alexdabast and @MKahmen , thank you for the feedback. I really do not know what is going on with project, but I didn't find any alternative for it, so I think we are stuck with it if you use angular. Right now I am off the grid, but I will be back in ten days and will make a pull request with this fix. Lets hope that it will end up in official fix.

@sebholstein
Copy link
Owner

Quick question: Can someone send a PR if you already know the exact line? That would help

PavleO added a commit to PavleO/angular-google-maps that referenced this issue Jun 10, 2019
fixes sebholstein#1586
Add two more checks before using  google.maps.LatLngBounds()
@ghost ghost closed this as completed in #1652 Jun 11, 2019
ghost pushed a commit that referenced this issue Jun 11, 2019
Add two more checks before using  google.maps.LatLngBounds()

fixes #1586
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants