如果我讀你的問題正確,您希望在其中任何一個觀察到鼠標懸停更新所有三個領域。 下面是一些應該幫助的咖啡腳本,下面是相應的javascript。
的CoffeeScript:
germany = [
germany1_poly
germany2_poly
germany3_poly
]
areas_effect = (areas) ->
for area in areas
area.setOptions({ fillColor: "#ff0000", strokeColor: "#ff0000" })
areas_observer = (areas) ->
for area in areas
google.maps.event.addListener(area, "mouseover", areas_effect(areas))
areas_observer(germany)
javascipt的:
var areas_effect, areas_observer, germany;
germany = [germany1_poly, germany2_poly, germany3_poly];
areas_effect = function(areas) {
var area, _i, _len, _results;
_results = [];
for (_i = 0, _len = areas.length; _i < _len; _i++) {
area = areas[_i];
_results.push(area.setOptions({
fillColor: "#ff0000",
strokeColor: "#ff0000"
}));
}
return _results;
};
areas_observer = function(areas) {
var area, _i, _len, _results;
_results = [];
for (_i = 0, _len = areas.length; _i < _len; _i++) {
area = areas[_i];
_results.push(google.maps.event.addListener(area, "mouseover", areas_effect(areas)));
}
return _results;
};
areas_observer(germany);