Dietmar wrote:
> 
> try this:
> 
> this.map.events.on({"changelayer": my_updateWFSLayer});
> 
> ...
> 
> function my_updateWFSLayer() {
> var l = new Array();
> for(var i=0;i<myWFSfromWMSLayer.length;i++) {
>  myWFSControl[i].deactivate();
>  for(var j=0;j<map.layers.length;j++) {
>  if(map.layers[j].displayInLayerSwitcher == true &&
> map.layers[j].getVisibility() == true &&  map.layers[j].calculateInRange()
> == true) {
>   if(myWFSfromWMSLayer[i].name == map.layers[j].name) {
>    l.push(i);
>   }
>  }
>  }
> }
> for(var i=0;i<l.length;i++) { myWFSControl[l[i]].activate(); }
> }
> 
> Regards
> 
> Dietmar Stolz
> 

So I received another response from Dietmar, many thanks btw :)

I sorta used ideas from this and came up with my own little thing...

However, it isn't exactly working as expected :(

The problem is a function I wrote removeLayersOutOfRange() is called before
the getfeatureinfo: function(event) but if I move it to the getfeatureinfo:
function(event), it also has no effect...

I need a way for my function removeLayersOutOfRange() to check on each and
every call to getfeatureinfo: function(event) and tell it which layers are
not wanted for getfeatureinfo...

var layersToBeQueried = [layerA, layerB, layerC, layerD, layerE];
                        
                        function removeLayersOutOfRange(layerArray){
                                for(var i = 0; i < layerArray.length; i++) {
                                        alert(layerArray[i].name);
                                                
if(layerArray[i].calculateInRange() == false){
                                                        layerArray.splice(i,1);
                                                }
                                }
                                return layerArray;
                        }
                        var info = new OpenLayers.Control.WMSGetFeatureInfo({
                            url: layerURL,
                            layerUrls: [layerURL],
                            title: 'Identify features by clicking',
                            layers: removeLayersOutOfRange(layersToBeQueried),
                            queryVisible: true,
                            eventListeners: {
                                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();


All your kind suggestions are greatly appreciated :)

Thank you,

elshae

-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Disable-WMSGetFeatureInfo-for-layers-which-are-currently-not-visible-tp5964206p5967675.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