Page constructors

I’m trying to use Leafletjs with Ionic 2 but I’m having some issues.
Since the page constructs every time, I can’t have a leaflet constructor on ionViewDidLoad, because the second time I open the page, leaflet warns the “Map container is already initialized.” and displays a white page.

So it made me think: if the .ts is constructing again, why not the html bind to it?

I’m really confused and can’t continue to do my project if the page is not a singleton or something like that :frowning:

Ps: I’m using setRoot to load the pages, but push is giving that error too.

Could you share some code?
Possibly a minimal demo even?
It’s kind of hard to help out without any code to share

Sure, sorry!

HomePage:
this.map = L.map(‘map’);
this.map.setView([-23.952159, -46.327820], 18);
L.tileLayer(global.map.tile, {
maxZoom: 18
}).addTo(this.map);

home.html:

MyApp:
setPage(page) {
this.menu.close();
this.nav.setRoot(page);
}

app.html:
<button detail-none ion-item no-lines *ngFor=“let p of pages” (click)=“setPage(p.component)”>



{{ p.title }}

For loading page i’m using setRoot from navcontroller.

Hi Fuyanli, did you got any resolution for the problem. I am also facing the same issue and stuck for couple of days. Please help.