我尝试使用鼠标悬停事件将颜色更改为一个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);
属性发生了变化,但我没有看到变化。为什么?
答案 0 :(得分:0)
我找到了解决方案
p1.setFillStyle({色 “#0000FF”});
p1.setStrokeStyle({色 “#0000FF”});