views:

37

answers:

1

I try change the color to one Gpolygon with a mouseover event

   map = new GMap2(document.getElementById("map_canvas")); 
   map.setCenter(new GLatLng(-39.875696,-72.624207), 9); 
   pLat = 0.2;
   pLon = 0.2;
   p1Lat = -40;
   p1Lon = -73;
   p1Coor = [
        new GLatLng(p1Lat, p1Lon - pLon),
        new GLatLng(p1Lat + pLat, p1Lon),
        new GLatLng(p1Lat, p1Lon + pLon),
        new GLatLng(p1Lat - pLat, p1Lon),
        new GLatLng(p1Lat, p1Lon - pLon)
     ];
   var p1 = new GPolygon(p1Coor, "#f33f00", 2, 1, "#ff0000", 0.2);
   GEvent.addListener(p1,"mouseover",function(overlay,latlng){
      p1.color = "#ffff00";
      alert(p1.color); 
  });
   map.addOverlay(p1);

the attribute change, but I don`t see the change. why ?

A: 

I find the solution with
p1.setFillStyle({color:"#0000ff"});
p1.setStrokeStyle({color:"#0000ff"});

JuanPablo