I have tried writting mouseover for an array of generated polygons but
it just doesn't seem to work.
I would post a link but the page requires data files to work.. but the
code snippet is pretty simple.
var polygons = [];
polygons = parsePolyXML();
for(var i = 0; i < polygons.length; i++ ){
map.addOverlay( polygons[i] );
} // To show the creation in case someone wanted to view it. There
isn't a problem with any of this. parsePolyXML() returns an array of
polygons that I have tested to make sure it's good.
for( var i = 0; i < polygons.length; i++ ) {
GEvent.addListener(polygons[i], "mouseover", function() {
var myHtml = "<b>Lot "+(i+1)+"</b><br/>";
>>>> map.openInfoWindowHtml( polygons[0].getBounds().getCenter(), myHtml); });
>>>> <<<<
GEvent.addListener(polygons[i], "mouseout", function() {
map.closeInfoWindow(); });
}
That code will put a mouseover for each polygon and all of them will
cause an infowindow at the first polygon.
The problem I have is that I cannot seem to find a way to put a
mouseover event given N number of polygons. If I change 0 to i (the
var to traverse the polygon array) it will give me undefined error
(because i is equal to length when the loop ends it tries to mouseover
polygon[length] which doesn't exist) I'm not too sure how to add a
listener for each polygon, any help?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---