我有一个带有缩放控件的 GeoExt 地图面板。当我的地图上的图层“超出范围”时,我真的很想禁用树面板中的一些节点,也就是它们setVisibility
设置为 false。我有我的 zoomend 事件工作,我也有一个 checkchange 事件工作,但是如果用户将缩放栏推到一个以上级别,则 checkchange 事件会被多次评估,另一个问题是即使在 zoomend 事件结束后 checkchange 仍然每次用户仅单击打开或关闭节点的复选框时都会触发。我真的需要一种方法来控制这个 checkchange 事件只运行一次并在用户不使用缩放栏时阻止它触发......
map.events.on({ "zoomend": function (e) {
layerTree.on("checkchange", function (node, checked) {
alert(node.text + "Inside event");
if(checked == false)
node.disable();
else if(checked == true)
node.enable();
});
if (this.getZoom() > 7) {
tib_villages.setVisibility(true);
tib_lakes.setVisibility(true);
tib_townships.setVisibility(true);
}
else {
tib_villages.setVisibility(false);
tib_lakes.setVisibility(false);
tib_townships.setVisibility(false);
if (this.getZoom() > 5) {
infrastructure.setVisibility(true);
geography.setVisibility(true);
geography2.setVisibility(true);
tib_countys.setVisibility(true);
}
else{
infrastructure.setVisibility(false);
geography.setVisibility(false);
geography2.setVisibility(false);
tib_countys.setVisibility(false);
}
}//end else
}//end function (e)
}); //end map.events.on
感谢您所有的时间和反馈:)
艾尔谢