0

我有一个带有缩放控件的 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

感谢您所有的时间和反馈:)

艾尔谢

4

1 回答 1

1

事实证明,这项工作已经为我们完成了 :)。http://trac.geoext.org/attachment/ticket/235/autoDisableLayerNode.patch有一个补丁,它将根据节点的 minScale/maxScale 属性等自动禁用/启用节点。我通过将此文件放入我的GeoExt 目录并在我的 GeoExt 目录中运行以下命令:

patch -p0 < autoDisableLayerNode.patch

我希望这有帮助!它为我创造了奇迹:)

艾尔谢

于 2010-10-28T16:21:48.717 回答