[OpenLayers-Users] Control.WMSGetFeatureInfo problem

Steve.Toutant at inspq.qc.ca Steve.Toutant at inspq.qc.ca
Thu Sep 3 11:18:19 EDT 2009


I moved the control creation just before 
map.addLayer(test);
And it is working. The query is done just for the specified layer.

So,
test = new OpenLayers.Layer.WMS('HLM', .....);
 
infoControls = 
{.......}
map.addLayer(test);
works

Someone can explain why I should define the control before adding the 
layer to the map. Because that means I must reorganise my code.
thanks
Steve

Steve Toutant, M. Sc.
Analyste en géomatique
Secteur environnement
Direction des risques biologiques, environnementaux et occupationnels
Institut national de santé publique du Québec
945, avenue Wolfe
Québec, Qc G1V 5B3 
Tél.: (418) 650-5115 #5281
Fax.: (418) 654-3144
steve.toutant at inspq.qc.ca
http://www.inspq.qc.ca
 




Andreas Hocevar <ahocevar at opengeo.org> 
03/09/2009 10:49 AM

A
Steve.Toutant at inspq.qc.ca
cc
users at openlayers.org
Objet
Re: [OpenLayers-Users] Control.WMSGetFeatureInfo problem








Hi Steve,

Steve.Toutant at inspq.qc.ca wrote:
> When I define the Control.WMSGetFeatureInfo if I don't specify the
> "layers:" properties, every visible layers with a Template in the
> mapfile are queried and I get the results. That is as expected. My
> problem is when I want to specify one layer to query. The request is
> not launched (I see nothing in firebug). Here is the code
>
> test = new OpenLayers.Layer.WMS('HLM',
> 
'http://10.2.192.247/cgi-bin/mapserv.exe?map=/ms4w/paccSante/map/paccsante_chaleur.map&',
> {layers: 'HLM', transparent: "true", format:"image/gif"},{isBaseLayer:
> false, visibility: false,singleTile:true});
> map.addLayer(test);

Note: visibilty is set to false. This means that the layer will be hidden.

> infoControls =
> {
> click: new OpenLayers.Control.WMSGetFeatureInfo({
> url:
> 
'http://10.2.192.247/cgi-bin/mapserv.exe?map=/ms4w/paccSante/map/paccsante_chaleur.map',
>
> title: 'Identify features by clicking',
> layers: [test],
> queryVisible: true,
> infoFormat:'text/html'
> })
> }

Note: queryVisible is set to true. This means that hidden layers won't
be queried.

So the behavior that the control does not issue any request is correct.
Set queryVisible to false, and you will be fine. If it still does not
work, remove the url property from the control config. This will be
taken from the layer and may prevent the control from issuing queries if
different from the layer url.

Regards,
Andreas.

-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090903/95ca09d4/attachment.html


More information about the Users mailing list