Hi, Do you mean visible OpenLayers layers or server side-layers ? Do you use (1) one OL layer per server-side layer or (2) are they all in the same OL layer ?
If (1) : loop through your map layers for each visible/inRange layer to get their params.['LAYERS'] property. If they come from the same server, you can merge them in a single request. If (2) : If you use MapServer and you have direct access to the mapfile, you could do the following. Please, anyone correct me if I'm wrong, but I think getfeatureinfo requests are made regardless of a layer's minscaledenom or maxscaledenom property. So you could create a template with leg_layer_minscale and leg_layer_maxscale values to get theses values from the server-side into a javascript array. Also, add the layer name at the same time (because that's the value to be added to the query_layers query property). Then, on click, you could loop through this array to check that the layers are currently visible (compare with current scale). See that (3) link for more details. Does that make sense ? (3) http://mapserver.org/output/html_legend.html Regards, Alexandre Ivan Carreira wrote: > Hi all, > > > > I have a problem. > > I need an expression to limit queries only to the layers that are visible at > that time on the map. > Queries are displayed via a popup. > The code where queries are made and displayed in the popup is as follows: > > var showInfo = function(event) { > > var pixel = event.xy; > var lonlat = this.getLonLatFromPixel(pixel); > var message = null; > var params = {}; > params['service'] = 'wms'; > params['request'] = 'GetFeatureInfo'; > params['version'] = '1.1.1'; > params['info_format'] = 'text/plain'; > params['srs'] = this.getProjection(); > params['bbox'] = this.getExtent().toBBOX(6); > params['width'] = this.getSize().w; > params['height'] = this.getSize().h; > params['feature_count'] = 1; > params['x'] = pixel.x; . > params['y'] = pixel.y; > params['layers'] = 'camino'; > params['query_layers'] = 'camino'; > > new OpenLayers.Request.GET({ > url: server, > async: false, > params: params, > success: function(data) { > message = data.responseText; > } > }); > > > > message = getHTML(message); > > > var popup = new OpenLayers.Popup.FramedCloud('popup', lonlat, > null, message, null, true, null); > > this.addPopup(popup); > > };//End of function showInfo() > > map.events.register('click', map, showInfo); > > > ------------------------------------------------------------------------ > ¿Eres del Madrid, del Barça, del Atleti...? Apoya a tu equipo en la > Zona Fan de MSN Deportes > <http://opiniones.msn.es/default.aspx/Futbol/Atletico-de-Madrid%20> > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > [email protected] > http://openlayers.org/mailman/listinfo/users > -- Alexandre Dubé Mapgears www.mapgears.com _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
