Having an issue with my marker loop where all markers respond with the same value when clicked.
Below is my code snippet:
for(a=0; a < prod.length; a++){
// adding marker to map
var myLatlng = new google.maps.LatLng(prod[a]['lat'],prod[a]['lon']);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: prod[a]['name']+" \n"+prod[a]['description'],
icon: image
});
google.maps.event.addListener(marker, "click", function() {
show_details(a);
});
}
The problem lies in the 'show_details' function where 'a' always has the same value.
Despite checking other solutions, I couldn't find a fix for this issue.