I think I got it!

var layersToBeQueried = [layerA, layerB, layerC, layerD, layerE];
                       
                        function removeLayersOutOfRange(layerArray){
                            var retArray = new Array();
                            for(var i = 0; i < layerArray.length; i++) {
                                //alert(layerArray[i].name);
                                if(layerArray[i].calculateInRange() == true){
                                    retArray.push(layerArray[i]);
                                }
                            } 
                            
                            return retArray;
                        }

            var info = new OpenLayers.Control.WMSGetFeatureInfo({
                   url: layerURL,
                   layerUrls: [layerURL],
                   title: 'Identify features by clicking',
                  // layers: removeLayersOutOfRange(layersToBeQueried),
                   queryVisible: true,
                   eventListeners: {
beforegetfeatureinfo: function(event) {
                                        this.layers =
removeLayersOutOfRange(layersToBeQueried);
                                },
                       getfeatureinfo: function(event){              
                         
                          if(event.text.length <= 687){}else{
                         
                        popup = new GeoExt.Popup({
                                title: "Popup",
                                location: event.xy,
                                autoScroll: true,
                                height: $('#myViewPort').height() - 250,
                                maximizable: true,
                                collapsible: true,
                                map: mapPanel.map,
                                anchored: true,
                                html: '<div id="popupWrap"></div>',
                                listeners: {
                                    close: function() {
                                        // closing a popup destroys it, but
our reference is truthy
                                        popup = null;
                                    }
                                }
                            });

                           popup.show();
                       
                          }//end if
                       }//end getfeatureinfo
                    }//end eventListeners
               });//end OpenLayers.Control.WMSGetFeatureInfo

               mapPanel.map.addControl(info);
               info.activate(); 

Changing the removeLayersOutOfRange() function a bit, in my previous post I
was looping through my array improperly because splice() was resizing it on
the fly.  Not specifying the layers in the config options but waiting to
specify them in the beforegetfeatureinfo event handler allows for a new set
of layers to be subjected for querying upon each different request.

Hope this helps someone and happy mapping,

elshae
-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Disable-WMSGetFeatureInfo-for-layers-which-are-currently-not-visible-tp5964206p5970371.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to