Good morning,
I have a piece of JS reading a XML file and creating a series of Polygons, I have then added an action listener to those polygons.
However as part of that function I want to have the count variable past to the function.
// Code to read XML file then loop through...
for (var i = 0; i < zones.length; i++)
// Create a "new" dbpolygon
dbpolygon = new google.maps.Polygon
({paths : polygonPoints});
// add to array
zonepolygons.push(dbpolygon);
zonepolygons[zonepolygons.length - 1].setMap(map);
var userclick = new google.maps.event.addListener(dbpolygon, 'click', function()
{
load_sample_results(field,i);
});
So I'm creating a new polygon eachtime and then adding an action listener to that newly created polygon object. However the function always has the variable 'i' set to the last count of i and not the count at creation.