Appeler un composant Leaflet plusieurs fois
Quand j'appelle mon composant une fois ca fonctionne :
Code:
<map-affiche [lat]="lat" [lng]="lng"></map-affiche>
mais quand je l'appelle plusieurs fois j'ai une erreur :
Citation:
"Map container is already initialized."
html :
Code:
<div id="map" class="center"></div>
typescript :
Code:
1 2 3 4 5 6 7 8 9 10
| @Input() lat: number;
@Input() lng: number;
ngOnInit() {
const map = L.map('map', {
center: [this.lat, this.lng],
zoom: 19,
attributionControl: false
});
} |
Avez vous une idée ? Merciiiiiiiiii
ps : j'ai essayé de rendre dynamic le container mais en vain :
html :
Code:
<div id="{{ 'map' + id }}" class="center"></div>
typescript :
Code:
1 2 3 4 5 6 7
| let variable = 'map' + this.id;
var map = L.map(this[variable], {
center: [this.lat, this.lng],
zoom: 19,
attributionControl: false
}); |