i have a problem with ngx-leaflet component from angular 2. after changing state of *ngif from true to false and again from false to true while map appeared, tiles render not occured. what to i do to avoid this problem?
this is my html code
<button (click)="showMap=!showMap">toggle</button>
<div *ngif="showMap">
<div [style.height.px]="mapHeight" leaflet
(leafletClick)="mapOnClick($event)"
[(leafletCenter)]="mapCenter"
[leafletOptions]="options"
(leafletMapReady)="onMapReady($event)"
[leafletLayers]="layers">
</div>
</div>
this is my typescript code
options = {
layers: [
tileLayer('http://tile.openstreetmap.org/...',
{ maxZoom: 18, attribution: '...' })
],
zoom: 12,
center: latLng(35.679966, 51.4)
};
map = null;
onMapReady(map: Map) {
this.map = map;
}
mapOnClick(evt) {
}
Use getter for
options
.Here is the working copy - https://stackblitz.com/edit/angular-w3ugkr