Blank page on Ionic2 alpha 54
Hello, I'm trying to use this library inside the Ionic2 sample app (tabs) with no success (testing in Chrome). There's obviously something I'm missing. One obvious thing missing is the bootstrap, but Ionic should bootstrap the root page on its own?
Either way, this could very well be a bug on the Ionic side, just want to make sure. Unfortunately I don't think it's possible to create codepens with Ionic2 at the moment, so here's a blob of code.
I npm'ed the library and added this import in app.js and tabs.js (the root page for the app):
import {
ANGULAR2_GOOGLE_MAPS_PROVIDERS,
ANGULAR2_GOOGLE_MAPS_DIRECTIVES
} from 'angular2-google-maps/core';
Created a new page:
import {
ANGULAR2_GOOGLE_MAPS_PROVIDERS,
ANGULAR2_GOOGLE_MAPS_DIRECTIVES
} from 'angular2-google-maps/core';
import {Page} from 'ionic/ionic';
@Page({
templateUrl: 'build/pages/mappa/mappa.html',
style: '.sebm-google-map-container { height: 300px; }',
providers: [
ANGULAR2_GOOGLE_MAPS_DIRECTIVES
]
})
export class Mappa {
constructor {
}
lat: number = 44.3;
lng: number = 33.2;
zoom: number = 10;
}
and the template:
<ion-navbar *navbar>
<ion-title>
Mappa
</ion-title>
</ion-navbar>
<ion-content class="Mappa" >
<sebm-google-map [latitude]="lat" [longitude]="lng" [zoom]="zoom"></sebm-google-map>
</ion-content>
Thank you!
@sphaso you are missing two things (when looking at your code):
- In the providers, you include ANGULAR2_GOOGLE_MAPS_DIRECTIVES but it must be ANGULAR2_GOOGLE_MAPS_PROVIDERS.
- You have to include the directives ANGULAR2_GOOGLE_MAPS_DIRECTIVES in a directives array
@Page({
templateUrl: 'build/pages/mappa/mappa.html',
style: '.sebm-google-map-container { height: 300px; }',
directives: [ANGULAR2_GOOGLE_MAPS_DIRECTIVES],
providers: [
ANGULAR2_GOOGLE_MAPS_PROVIDERS
]
})
Thank you! Now I get an error when loading the page: "No Directive annotation found on SebmGoogleMap". Any idea?
Try to update the versions for the following packages in your package.json file:
"dependencies": {
"angular2": "^2.0.0-beta.2",
"angular2-google-maps": "^0.6.1"
}
Then run npm install in the terminal and restart your app.
I was already using those versions. Anything else I can do to help?
@sphaso played with Ionic and angular2-google-maps a few days ago. Uploaded my working app here, so you can diff with your code: https://github.com/SebastianM/MyIonic2Project
For running this project: npm install ionic serve
The angular2-google-maps related code is here: https://github.com/SebastianM/MyIonic2Project/blob/master/app/pages/hello-ionic/hello-ionic.ts
Closing this for now, feel free to reopen if you find any bugs/issues working with ionic.
Hi.
I've reopened this issue because I have the exact same problem. I'm working with Ionic 2 (2.0.0-beta.6) and Angular 2 (2.0.0-beta.15).
I have the latest version of angular2-google-maps.
I'm using this package as specified in the documentation & comments.
Here is my code :
import {Page} from 'ionic-angular';
import {ANGULAR2_GOOGLE_MAPS_DIRECTIVES, SebmGoogleMap} from 'angular2-google-maps/core';
@Page({
directives: [ANGULAR2_GOOGLE_MAPS_DIRECTIVES, SebmGoogleMap],
template: `
<sebm-google-map [latitude]="lat" [longitude]="lng"></sebm-google-map>
`,
styles: [`
.sebm-google-map-container {
height: 300px;
}
`]
})
export class MapPage {
lat: number = -34;
lng: number = 138;
constructor() {}
}
And the error:
Uncaught (in promise): No Directive annotation found on SebmGoogleMap
I'm currently investigating, I'll update this comment if I found anything.
Hi @mildful,
the latest angular2-google-maps version (0.10.0) supports angular2-rc.1 only - the current docs/getting started guide is out of date (sorry, update of the docs coming soon).
import {ANGULAR2_GOOGLE_MAPS_DIRECTIVES} from 'angular2-google-maps/core';
is now
{GOOGLE_MAPS_PROVIDERS} from 'angular2-google-maps/core';