<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
Thanks
for the help. I am starting to use openlayers and I do not know much
about this. <br>The idea is: <br>-Deactivating a layer in the legend,&nbsp; make the query, and not display the popup<br>-Activating a layer in the legend, make the query, and not display the popup<br><br>&nbsp;Being
tested with the following: <br><br><div style="text-align: left;" id="EC_result_box" dir="ltr">
<div style="text-align: left;" id="EC_result_box" dir="ltr">var showInfo = function(event) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; var layers&nbsp; = map.layers; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(event)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (var i = 0; i &lt; layers.length; i++) {<br><br>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (!layers[i].getVisibility())<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br><br><br> but I do not know how to continue.<br><br> Regards,<br><br>Iván<br></div>
</div><br><br><br><br><br>&gt; <br>&gt; Hi,<br>&gt; <br>&gt;   Do you mean visible OpenLayers layers or server side-layers ?  Do you <br>&gt; use (1) one OL layer per server-side layer or (2) are they all in the <br>&gt; same OL layer ?<br>&gt; <br>&gt;   If (1) : loop through your map layers for each visible/inRange layer <br>&gt; to get their params.['LAYERS'] property.  If they come from the same <br>&gt; server, you can merge them in a single request.<br>&gt; <br>&gt;   If (2) : If you use MapServer and you have direct access to the <br>&gt; mapfile, you could do the following.  Please, anyone correct me if I'm <br>&gt; wrong, but I think getfeatureinfo requests are made regardless of a <br>&gt; layer's minscaledenom or maxscaledenom property.  So you could create a <br>&gt; template with leg_layer_minscale and leg_layer_maxscale values to get <br>&gt; theses values from the server-side into a javascript array.  Also, add <br>&gt; the layer name at the same time (because that's the value to be added to <br>&gt; the query_layers query property). Then, on click, you could loop through <br>&gt; this array to check that the layers are currently visible (compare with <br>&gt; current scale).  See that (3) link for more details.  Does that make sense ?<br>&gt; <br>&gt; (3) http://mapserver.org/output/html_legend.html<br>&gt; <br>&gt; Regards,<br>&gt; <br>&gt; Alexandre<br>&gt; <br>&gt; Ivan Carreira wrote:<br>&gt; &gt; Hi all,<br>&gt; &gt;<br>&gt; &gt;  <br>&gt; &gt;<br>&gt; &gt; I have a problem.<br>&gt; &gt;<br>&gt; &gt; I need an expression to limit queries only to the layers that are visible at that time on the map.<br>&gt; &gt; Queries are displayed via a popup.<br>&gt; &gt; The code where queries are made and displayed in the popup is as follows:<br>&gt; &gt;<br>&gt; &gt; var showInfo = function(event) {<br>&gt; &gt;                                 <br>&gt; &gt;                 var pixel = event.xy;<br>&gt; &gt;                 var lonlat = this.getLonLatFromPixel(pixel);<br>&gt; &gt;                 var message = null;<br>&gt; &gt;                 var params = {}; <br>&gt; &gt;                 params['service'] = 'wms'; <br>&gt; &gt;                 params['request'] = 'GetFeatureInfo'; <br>&gt; &gt;                 params['version'] = '1.1.1'; <br>&gt; &gt;                 params['info_format'] = 'text/plain';<br>&gt; &gt;                 params['srs'] = this.getProjection();<br>&gt; &gt;                 params['bbox'] = this.getExtent().toBBOX(6);<br>&gt; &gt;                 params['width'] = this.getSize().w; <br>&gt; &gt;                 params['height'] = this.getSize().h;<br>&gt; &gt;                 params['feature_count'] = 1; <br>&gt; &gt;                 params['x'] = pixel.x; .<br>&gt; &gt;                 params['y'] = pixel.y; <br>&gt; &gt;                 params['layers'] = 'camino'; <br>&gt; &gt;                 params['query_layers'] = 'camino';<br>&gt; &gt;                 <br>&gt; &gt;                 new OpenLayers.Request.GET({<br>&gt; &gt;                         url: server,<br>&gt; &gt;                         async: false,<br>&gt; &gt;                         params: params,<br>&gt; &gt;                         success: function(data) {<br>&gt; &gt;                                 message = data.responseText;<br>&gt; &gt;                         }<br>&gt; &gt;                 });<br>&gt; &gt;                 <br>&gt; &gt;                 <br>&gt; &gt;                 <br>&gt; &gt;                 message = getHTML(message);<br>&gt; &gt;                 <br>&gt; &gt;                 <br>&gt; &gt;                 var popup = new OpenLayers.Popup.FramedCloud('popup', lonlat, null, message, null, true, null);<br>&gt; &gt;                 <br>&gt; &gt;                 this.addPopup(popup);<br>&gt; &gt;<br>&gt; &gt; };//End of function showInfo()<br>&gt; &gt;<br>&gt; &gt;         map.events.register('click', map, showInfo);<br>&gt; &gt;   <br>&gt; &gt;<br><br>&gt; <br><br /><hr />Ahora, GRATIS Hotmail en tu móvil  <a href='http://serviciosmoviles.es.msn.com/hotmail.aspx' target='_new'>¡Descúbrelo aquí!</a></body>
</html>