1

我尝试使用鼠标悬停事件将颜色更改为一个 Gpolygon

   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);

属性发生了变化,但我没有看到变化。为什么 ?

4

1 回答 1

0

我找到解决方案
p1.setFillStyle({color:"#0000ff"});
p1.setStrokeStyle({color:"#0000ff"});

于 2010-08-21T23:17:37.977 回答