Sorry Mike, I changed my code but it still doesn't work. It did not
raise any error. when I move mouse over the polygon, the alert("Hello
worl") does not work. :(
Herei is my code, please check my error. Really thanks to you so much!
var polys = [];
var labels = [];
var htmls = [];
function CreatePolygon(pts, label, html) {
        var poly = new GPolygon(pts,"#000000",0,0,"#0000CC",0,
{clickable:false});
        polys.push(poly);
        labels.push(label);
        htmls.push(html);
        GEvent.addListener(poly, "mouseover", function() {
                alert("Hello World");
        });
        return poly;
}

var request = GXmlHttp.create();
request.open("GET", "companies.xml", true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
  var xmlDoc = GXml.parse(request.responseText);

  // ========= Now process the polylines ===========
  var companies =
xmlDoc.documentElement.getElementsByTagName("company");

  // read each line
  for (var a = 0; a < companies.length; a++) {
        // get any state attributes
        var label  = companies[a].getAttribute("name");
        // read each point on that line
        var points = companies[a].getElementsByTagName("point");
        var pts = [];
        for (var i = 0; i < points.length; i++) {
           pts[i] = new GLatLng(parseFloat(points[i].getAttribute("lat")),
                                                   
parseFloat(points[i].getAttribute("lng")));
        }
        var htmlObject = companies[a].getElementsByTagName("html");
        if (htmlObject.length > 0)
                var html = htmlObject[0].childNodes[0].nodeValue;
        else
                var html = "";
                // Create Polygon
        var myPoly = CreatePolygon(pts, label, html);
        map.addOverlay(myPoly);
  }
  // ================================================
}
}
request.send(null);



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to