The following code is running in a loop, it is simply adding HTML markers in a map and attach click event for each of the markers. Click event is attached with all the markers and I can see the alert but the popup appears with the last markers only, which means only the last marker is being passed as argument to the event.
var marker = new atlas.HtmlMarker({
position: [long, lat],
text: step,
popup: new atlas.Popup({
content: 'test',
pixelOffset: [0, -30],
closeButton: false
})
});
markers.push(marker);
map.events.add('click', marker, () => {
marker.togglePopup();
});
Can anyone please help how can we send all the markers to the event handler so the respective popups will appear when clicked on the marker?
Thanks.