I have a collection of marker objects named markers
. I am currently utilizing a for loop to assign event listeners to each one. However, I am encountering difficulty in determining which specific marker was clicked.
This is the current code snippet I have:
for(var i = 0; i < this.markers.length; i++) //attaches listener to all markers
{
google.maps.event.addListener(this.markers[i], "click", () =>
{
//need a way to identify the clicked marker
});
}
I've experimented with passing arguments to the arrow function without success. Are there any suggestions or alternatives? The usage of an arrow function is not mandatory as long as the function can provide the index of the correct marker.