I am iterating through several polygons and happily setting their maps. I am now wanting to add an event listener to those polygons which will trigger a function based on either its position within the MVC array or a variable I can set.
I have tried : for (var i = 0; i < polygonArray.length; i++) { .... new google.maps.event.addListener(polygon , 'click', anotherFunction(i)); ... } and new google.maps.event.addListener(polygon, 'click', function() { anotherFunction(i); }); however I have successfully achieved a similar solution by using an infobox and adding, this means the user has to click the infobox label rather than the actual polygon. boxText.innerHTML ="<div onclick='anotherFunction("+i+")'>"+Name+"</div>" Any pointers in the right direction would be very gratefully received. James -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-js-api-v3/-/7lmb_0ElfDAJ. To post to this group, send email to google-maps-js-api-v3@googlegroups.com. To unsubscribe from this group, send email to google-maps-js-api-v3+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.