Angular-google-maps: InvalidValueError when upgrading from beta.3 to beta.5

Created on 17 Oct 2018  路  5Comments  路  Source: SebastianM/angular-google-maps

Issue description
Upgrading from 1.0.0-beta.3 to 1.0.0-beta.5 causes the following error in Chrome:

ERROR Error: Uncaught (in promise): InvalidValueError: not a LatLngBounds or LatLngBoundsLiteral: not an Object Error

This only happens on maps that I am using the following function on. Any other maps with a single marker do not cause the error.

this.mapsAPILoader.load().then(() => {
  this.latlngBounds = new window['google'].maps.LatLngBounds();
  for (const point of this.points) {
     this.latlngBounds.extend(new window['google'].maps.LatLng(point['lat'], point['lng']));
  }
});

After diving into it a little more, it is the [fitBounds] input on the agm-map tag that is causing the error. Has the format of how we are supposed to pass the data object into [fitBounds] changed?

<agm-map [latitude]=""
           [longitude]=""
           [zoom]=""
           [fitBounds]="latlngBounds"> <!-- passing it into fitBounds is what is causing the error -->

Steps to reproduce and a minimal demo of the problem

Here is a stackblitz, that shows the error. Changing the agm/core dependency to beta.3 will fix the error.
https://stackblitz.com/edit/angular-google-maps-demo-fjugvd?file=app%2Fapp.module.ts

_What steps should we try in your demo to see the problem?_

  • Fork the repo
  • Run the code and open a console to see the error.
  • In package.json, chagne agm/core to beta.3
  • Save, and make sure the dependencies dropdown is beta.3
  • Run the code and open a console to see no error

Current behavior
Error being thrown when upgrading when previous version did not throw the error. Or an explanation of a proper way to upgrade.

Expected/desired behavior
No errors should be caused by the upgrade.

angular2 & angular-google-maps version
1.0.0-beta.3 works
1.0.0-beta.4 errors
1.0.0-beta.5 errors

Other information

image

Most helpful comment

with setting the initial value to false worked for me.
this.latlngBounds : any = false;

All 5 comments

Getting the same issue here. I'm giving the bounds a value on ngAfterViewInit.

try this it worked for me:

with setting the initial value to false worked for me.
this.latlngBounds : any = false;

@chakstud that solves the error message. I think there is still something underlying that is wrong but seeing as this has had no activity for the last 3 months and this technically solves my issue , I will close it.

@chakstud thanks for your solution.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stot3 picture stot3  路  3Comments

DeveloperAdd007 picture DeveloperAdd007  路  3Comments

nthonymiller picture nthonymiller  路  4Comments

matishw picture matishw  路  3Comments

marcelinobadin picture marcelinobadin  路  3Comments