question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to display maps in page. ERROR TypeError: Object(...) is not a function

See original GitHub issue

I followed exactly steps in Getting Started, however I got error during page load and the maps cannot be load.

Steps to reproduce

  1. Install agm core module through terminal npm install @agm/core --save

  2. 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 { }
    
  3. Add <agm-map /> component in my html

    <agm-map [latitude]="latitude" [longitude]="longitude">
    </agm-map>
    
  4. Add height to <agm-map /> component in my app.component.scss

    agm-map {
        height : 600px;
    }
    
  5. Add latitude and longitude property in app.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(){}
    
    }
    
  6. Run the application using ng serve command

  7. 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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:22

github_iconTop GitHub Comments

29reactions
vgremcommented, Oct 10, 2018

Since you are creating Angular: 5 application :

Angular: 5.2.11

RxJS 5.x package is installed with it.

But starting from @agm/core@1.0.0-beta.4 the library has a dependency to RxJS 6.x, that’s the reason why this error occurs.

So, the solution would to update RxJS from from 5.x to 6.x:

npm uninstall rxjs
npm install rxjs@6 rxjs-compat@6 --save
6reactions
gtzinoscommented, Feb 28, 2019

Yes i used "@agm/core": "1.0.0-beta.3" and now it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to display maps in page. ERROR TypeError: Object ...
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 ......
Read more >
Uncaught TypeError: object is not a function on Google Maps
This seems to prevent the creation of RichMarker markers. The code so far is very basic, I've been interacting with the console to...
Read more >
TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >
TypeError Handling in React.js for Map Function | Pluralsight
This error occurs because your data is not an array. The .map() function only works with arrays. First, you'll need to confirm your...
Read more >
map is suddenly not a function? - JavaScript
This error is usually due to the fact that .map() is an array method, and does not work with other data types like...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found