[Users] Disable Nodes on Zoom Event

IT Intern itintern12 at gmail.com
Thu Oct 28 16:08:22 CEST 2010


Hello GeoExt Users,

I have a zoom event that when a user zoom in and out of my map certain
layers I setVisibility(false).  Now what I would like to do is have another
event inside that event which disables the nodes of those layers when their
setVisibilty(false) and enables them back when setVisibility(true).  I have
some code and it kinda works, but the problem is the checkchange event does
not only work when the zoomend event is done, but also anytime a user clicks
the layer nodes.  I played a little with stopPropagation and that didn't do
anything for me.  Actually I think my zoomend event could be much better
coded and I would really love some suggestions.  I appreciate everyone
taking their time to help me :)

elshae

Code:

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);

//alert(layerTree.tib_villages.node.text);

                        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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20101028/30f100fb/attachment.htm 


More information about the Users mailing list