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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -