I have an Ionic v2 app.
I've been trying to implement angular2-google-maps for ages but keep getting the error:
TypeError: ctorParameters.map is not a function
My packages.json
(dependencies):
"dependencies": {
"@angular/common": "2.3.1",
"@angular/compiler": "2.3.1",
"@angular/compiler-cli": "2.3.1",
"@angular/core": "2.3.1",
"@angular/forms": "2.3.1",
"@angular/http": "2.3.1",
"@angular/platform-browser": "2.3.1",
"@angular/platform-browser-dynamic": "2.3.1",
"@angular/platform-server": "2.3.1",
"@ionic/storage": "1.1.6",
"angular2-google-maps": "^0.17.0",
"angularfire2": "^2.0.0-beta.6",
"firebase": "^3.6.4",
"ionic-angular": "2.0.0-rc.4",
"ionic-native": "2.2.3",
"ionicons": "3.0.0",
"rxjs": "5.0.0-beta.12",
"zone.js": "0.7.4"
},
Looking here and questions similar, I updated all of my packages to (what I think to be) the correct versions (i.e. ionic-angular
from rc3 to rc4) as, from what I can see, this error is usually caused by a mismatch of package versions.
I followed this tutorial but he talks of a different problem with integrating with ionic and didn't fix my own.
My app.module.ts
follows the same as the tutorial:
import { AgmCoreModule } from "angular2-google-maps/core";
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
// AgmCoreModule.forRoot({
// apiKey: "AIzaSyDUdGaRHXhN5oy5zpETRll8KsHnvx19_9Y"
// }),
AngularFireModule.initializeApp(firebaseConfig, firebaseAuthConfig)
],
As that code is, it would work. However, if I uncomment AgmCoreModule.forRoot()
that is when I get the error.
I cannot find anywhere where anyone has replicated or had the same error.
Also, starting a blank ionic v2 project with the same dependencies and enabling AgmCoreModule.forRoot()
works which leads me to believe that it might be my project. However, all the configs are the exact same and I don't know where else would cause this error.
ANSWER:
The error was the angular2-google-maps
version. I was using 0.17.0
whereas 0.16.0
is required for an Ionic v2 app. The answer below describes that downgrading your angular version may help as well but I did not deem this necessary. In any case, this is my new set of dependencies in package.json
:
"dependencies": {
"@angular/common": "2.2.1",
"@angular/compiler": "2.2.1",
"@angular/compiler-cli": "2.2.1",
"@angular/core": "2.2.1",
"@angular/forms": "2.2.1",
"@angular/http": "2.2.1",
"@angular/platform-browser": "2.2.1",
"@angular/platform-browser-dynamic": "2.2.1",
"@angular/platform-server": "2.2.1",
"@ionic/storage": "1.1.7",
"angular2-google-maps": "0.16.0",
"angularfire2": "^2.0.0-beta.6",
"firebase": "^3.6.4",
"ionic-angular": "2.0.0-rc.4",
"ionic-native": "2.2.11",
"ionicons": "3.0.0",
"rxjs": "5.0.0-beta.12",
"zone.js": "0.6.26"
}