<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, 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> 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> var layers = map.layers; <br> <br> if(event)<br> {<br> for (var i = 0; i < layers.length; i++) {<br><br> if (!layers[i].getVisibility())<br> <br> {<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>> <br>> Hi,<br>> <br>> Do you mean visible OpenLayers layers or server side-layers ? Do you <br>> use (1) one OL layer per server-side layer or (2) are they all in the <br>> same OL layer ?<br>> <br>> If (1) : loop through your map layers for each visible/inRange layer <br>> to get their params.['LAYERS'] property. If they come from the same <br>> server, you can merge them in a single request.<br>> <br>> If (2) : If you use MapServer and you have direct access to the <br>> mapfile, you could do the following. Please, anyone correct me if I'm <br>> wrong, but I think getfeatureinfo requests are made regardless of a <br>> layer's minscaledenom or maxscaledenom property. So you could create a <br>> template with leg_layer_minscale and leg_layer_maxscale values to get <br>> theses values from the server-side into a javascript array. Also, add <br>> the layer name at the same time (because that's the value to be added to <br>> the query_layers query property). Then, on click, you could loop through <br>> this array to check that the layers are currently visible (compare with <br>> current scale). See that (3) link for more details. Does that make sense ?<br>> <br>> (3) http://mapserver.org/output/html_legend.html<br>> <br>> Regards,<br>> <br>> Alexandre<br>> <br>> Ivan Carreira wrote:<br>> > Hi all,<br>> ><br>> > <br>> ><br>> > I have a problem.<br>> ><br>> > I need an expression to limit queries only to the layers that are visible at that time on the map.<br>> > Queries are displayed via a popup.<br>> > The code where queries are made and displayed in the popup is as follows:<br>> ><br>> > var showInfo = function(event) {<br>> >                                 <br>> > var pixel = event.xy;<br>> > var lonlat = this.getLonLatFromPixel(pixel);<br>> > var message = null;<br>> > var params = {}; <br>> > params['service'] = 'wms'; <br>> > params['request'] = 'GetFeatureInfo'; <br>> > params['version'] = '1.1.1'; <br>> > params['info_format'] = 'text/plain';<br>> > params['srs'] = this.getProjection();<br>> > params['bbox'] = this.getExtent().toBBOX(6);<br>> > params['width'] = this.getSize().w; <br>> > params['height'] = this.getSize().h;<br>> > params['feature_count'] = 1; <br>> > params['x'] = pixel.x; .<br>> > params['y'] = pixel.y; <br>> > params['layers'] = 'camino'; <br>> > params['query_layers'] = 'camino';<br>> >                 <br>> >                 new OpenLayers.Request.GET({<br>> >                         url: server,<br>> >                         async: false,<br>> >                         params: params,<br>> >                         success: function(data) {<br>> >                                 message = data.responseText;<br>> >                         }<br>> >                 });<br>> >                 <br>> >                 <br>> >                 <br>> >                 message = getHTML(message);<br>> >                 <br>> >                 <br>> >                 var popup = new OpenLayers.Popup.FramedCloud('popup', lonlat, null, message, null, true, null);<br>> >                 <br>> >                 this.addPopup(popup);<br>> ><br>> > };//End of function showInfo()<br>> ><br>> >         map.events.register('click', map, showInfo);<br>> > <br>> ><br><br>> <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>