在另一个事件被解雇后才开火

时间:2022-12-03 20:30:32

I have a GeoExt map panel with a zoom control. I'd really like to disable some of the nodes in a tree panel when the layers on my map are "out of range" aka their setVisibility is set to false. I have my zoomend event working and I also have a checkchange event working, but the checkchange event gets evaluated more than once if the user pushes the zoombar more than one level and the other problem is that even after the zoomend event is over the checkchange still gets fired every time the user merely clicks the node's checkbox on or off. I really need a way to control this checkchange event to only run once and to stop it from firing if the user is not using the zoombar...

我有一个带缩放控件的GeoExt地图面板。当地图上的图层“超出范围”时,我真的想要禁用树面板中的一些节点,也就是说他们的setVisibility设置为false。我有我的zoomend事件工作,我也有一个checkchange事件工作,但如果用户将zoombar推到多个级别,则checkchange事件会被多次评估,另一个问题是即使在zoomend事件结束后仍然检查更改每次用户只是打开或关闭节点的复选框时都会被触发。我真的需要一种方法来控制这个checkchange事件只运行一次,如果用户没有使用zoombar就阻止它被触发...

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

Thank you for all your time and feedback :)

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

elshae

elshae

1 个解决方案

#1


1  

It turns out that the work has already been done for us :). There is a patch at http://trac.geoext.org/attachment/ticket/235/autoDisableLayerNode.patch which will automatically disable/enable nodes based on their minScale/maxScale properties etc. I applied the patch by putting this file in my GeoExt directory and running the following command in my GeoExt directory:

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

patch -p0 < autoDisableLayerNode.patch

patch -p0

I hope this helps! It worked wonders for me :)

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

elshae

elshae

#1


1  

It turns out that the work has already been done for us :). There is a patch at http://trac.geoext.org/attachment/ticket/235/autoDisableLayerNode.patch which will automatically disable/enable nodes based on their minScale/maxScale properties etc. I applied the patch by putting this file in my GeoExt directory and running the following command in my GeoExt directory:

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

patch -p0 < autoDisableLayerNode.patch

patch -p0

I hope this helps! It worked wonders for me :)

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

elshae

elshae