javascript - Trying to put count variable in action Listener in Google Maps v3 however always calls last count figure -
good morning,
i have piece of js reading xml file , creating series of polygons, have added action listener polygons.
however part of function want have count variable past function.
// code read xml file loop through... (var = 0; < zones.length; i++) // create "new" dbpolygon dbpolygon = new google.maps.polygon ({paths : polygonpoints}); // add 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 new polygon eachtime , adding action listener newly created polygon object. function has variable 'i' set last count of , not count @ creation.
take @ answer shog9
you have sourround .addeventlistener() let or statement.
Comments
Post a Comment