[OpenLayers-Users] Query only in visible layers
Ivan Carreira
carreicm at hotmail.com
Tue May 5 11:14:37 EDT 2009
Thanks
for the help. I am starting to use openlayers and I do not know much
about this.
The idea is:
-Deactivating a layer in the legend, make the query, and not display the popup
-Activating a layer in the legend, make the query, and not display the popup
Being
tested with the following:
var showInfo = function(event) {
var layers = map.layers;
if(event)
{
for (var i = 0; i < layers.length; i++) {
if (!layers[i].getVisibility())
{
but I do not know how to continue.
Regards,
Iván
>
> 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);
> >
> >
>
_________________________________________________________________
Descárgate ahora el nuevo Internet Explorer 8 y ten a tu alcance todos los servicios de Windows Live ¡Gratis!
http://ie8.msn.com/microsoft/internet-explorer-8/es-es/ie8.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090505/84bd6c6f/attachment.html
More information about the Users
mailing list