hi
I have a page where given a select to the user he can switch the leaflet map I show.
After a initial leaflet map load, my problem is when i want to refresh the map.
I always get “Map container is already initialized”:
My Code
ionViewDidEnter() {
this.loadmap();//خواندن نقشه
}
//نشان دادن نقشه
loadmap() {
this.map = leaflet.map("map").fitWorld();//ایجاد نقشه
// استفاده از نقشه ایرانی
leaflet.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
//attributions: 'www.tphangout.com',
maxZoom: 18//سایز نمایش نقشه
}).addTo(this.map);
// تابع مشخص کردن لوکیشن خود
if (this.offOnLocationFlag) {
//this.myLoc();
} else {
}
if (this.myLocFlag) {
this.myLocFlag = false;
this.myLoc();
}
//کلیک برروی نقشه و گرفتن مشخصات
this.clickMap();
if (this.latF) {
this.latF = false;
let marker: any = leaflet.marker([this.lat, this.lng], { icon: this.selfIcon });
this.map.addLayer(marker);
this.temploc = marker;
this.map.flyTo([this.lat, this.lng], 16);//نمایش محل موقعیت
}
}