angular-google-maps: Failed to display maps in page. ERROR TypeError: Object(...) is not a function
I followed exactly steps in Getting Started, however I got error during page load and the maps cannot be load.
Steps to reproduce
-
Install agm core module through terminal
npm install @agm/core --save
-
Include AgmCoreModule in
app.module.ts
import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; import { AgmCoreModule } from '@agm/core'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, AgmCoreModule.forRoot({ apiKey : 'my_api_key' }) ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }
-
Add
<agm-map />
component in my html<agm-map [latitude]="latitude" [longitude]="longitude"> </agm-map>
-
Add height to
<agm-map />
component in myapp.component.scss
agm-map { height : 600px; }
-
Add
latitude
andlongitude
property inapp.component.ts
import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) export class AppComponent { latitude: number = 51.678418; longitude: number = 7.809007; constructor(){} }
-
Run the application using
ng serve
command -
Open
http://localhost:4200
in my browser just to see blank page with below’s error in developer console.ERROR TypeError: Object(...) is not a function at new FitBoundsService (fit-bounds.js:31) at createClass (core.js:12481) at _createProviderInstance (core.js:12458) at createProviderInstance (core.js:12299) at createViewNodes (core.js:13771) at callViewAction (core.js:14218) at execComponentViewsAction (core.js:14127) at createViewNodes (core.js:13812) at createRootView (core.js:13673) at callWithDebugContext (core.js:15098)
Expected/desired behavior I want to display a map without any marker in it.
angular2 & angular-google-maps version
Angular CLI: 1.6.8
Node: 9.5.0
OS: linux x64
Angular: 5.2.11
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.6.8
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.8
@schematics/angular: 0.1.17
typescript: 2.5.3
webpack: 3.10.0
AGM Version : @agm/core@1.0.0-beta.5
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 22
Commits related to this issue
- fix agm https://github.com/SebastianM/angular-google-maps/issues/1511 — committed to entrecode/ec.components by felixroos 6 years ago
Since you are creating Angular: 5 application :
RxJS 5.x
package is installed with it.But starting from
@agm/core@1.0.0-beta.4
the library has a dependency toRxJS 6.x
, that’s the reason why this error occurs.So, the solution would to update RxJS from from 5.x to 6.x:
Yes i used
"@agm/core": "1.0.0-beta.3"
and now it works.We also experienced the same error. Previously had “@agm/core”: “^1.0.0-beta.2” which was installing “@agm/core@1.0.0-beta.3” but recently has been installing “@agm/core@1.0.0-beta.5”. Which broke our site. Changing the package.json to specify exact version is our workaround for now. “@agm/core”: “1.0.0-beta.3”.
I think you used the dependency in package.json like this :
"@agm/core": "^1.0.0-beta.2"
When you use^
… npm will optimize your dependency, trying to keep the package up-to-date until this package is compatible with the others… but in this case the npm thinks wrongI used this syntax and the npm installed the beta.5 … You can check this if u search the agm folder in node_modules and open the agm’s package.json… there is a “version” key for it.
If I delete the
^
before the version number I force the npm to use this version and this solved my problem.I hope it helps.
Thank you @vgrem your solution is great, very fine
it’s work very wel for me.
@vgrem I was facing the same issue. Yours reply worked for me. Thanx much
Thank you !!!
@vgrem Thanks !!!
@vgrem Thank you, work for me.
@vgrem work for me
Work for me also. Thank you.
may be, you have a syntax error. check your code very well
RROR in node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ‘;’ expected.
i’m seeing that << ‘;’ expected. >>, check your syntax because Angular like soft code.
if the Error persist, tell me again
Le ven. 8 févr. 2019 à 13:18, Alessandro Oliveira Silva < notifications@github.com> a écrit :