Angular2-google-maps in ionic 2


#1

Hi all!

I’m trying to setup angular2-google-maps component for ionic2 app, but getting error on build.

ngc error: Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in E:/node/hotby.me/ionic2-angular2-google-maps-example/.tmp/app/app.module.ts, resolving symbol AppModule in E:/node/hotby.me/ionic2-angular2-google-maps-example/.tmp/app/app.module.ts

Can someone help me please?

Here is the module definition file

And here is full project repo, which is just ionic2 blank template with modified app.module.ts fil


#2

Ok, I’ve finally managed to run the angular2-google-maps in my app.

The issue was is caused by Angular2 ahead of time compiler and angular2-google maps incompatibility.
If anyone will have same issue, here are the steps I’ve done, to make it work in dev environment without AoT

  1. I’ve updated ionic build scripts lib, so now it doesn’t make AoT compiling for dev build

  2. You need to import angular2-google-maps by following method, otherwise it doesn’t work after rollup

    import { AgmCoreModule } from ‘angular2-google-maps/esm/core/index.js’;

  3. Add the AgmCoreModule to imports field in your app module

    AgmCoreModule.forRoot({
    apiKey: ‘YOUR-GOOGLE-API-KEY’
    })

Now you’ll to be able to use the
This works only for build in dev environment yet, untill angular2-google-maps plugin will add AoT support.

Regards
Gevorg


#3

Isn’t there a way to configure rollup so that AoT compiling is not applied on modules which don’t have support for AoT?


#4

That’s an interesting question. I don’t know, but I think that rollup has nothing to do with AoT, and the error is given during ngc task, which is AoT compilation task, and rollup comes after in bundle task

I may be wrong though.


#5

There is a actually an issue open for AoT support at: https://github.com/SebastianM/angular2-google-maps/issues/629 on which you might want to keep an eye on.