консоль лог срабатывает сразу
setMarkers(rcs) {
new Promise((resolve, reject) => {
rcs.forEach((residential, i) => {
setTimeout(() => {
let myDivIcon = DG.divIcon({
iconSize: [30, 30],
className: "marker-custom",
html: this.setMiniMarker(residential)
});
this.popupMap = DG.popup({
className: "test-name",
closeButton: false,
offset: DG.point(0, 1),
setZoomMarker: false
}).setContent(this.setPopupMarker(residential));
this.coordinates = [residential.latitude, residential.longitude];
DG.marker(this.coordinates, { icon: myDivIcon })
.addTo(this.markers)
.bindPopup(this.popupMap);
}, i * 50);
});
resolve("промис");
})
.then(response => {
console.log(response);
this.markers.addTo(this.map);
this.map.fitBounds(this.markers.getBounds());
this.markers.on("click", event => {
//при наведении.mouseover, click на маркер
if (event.originalEvent.target.closest("[data-id]")) {
let residentialId = Number(
event.originalEvent.target.closest("[data-id]").dataset.id
);
this.setResidentialId(residentialId);
// добавление класса с задержкой для ожидания создания данных
if (this.countFunctionMarker === 0) {
setTimeout(() => (this.isOpenRc = true), 200);
} else {
this.isOpenRc = true;
}
this.countFunctionMarker++;
}
});
})
.catch(error => {
console.error(error);
});
},