[mapserver-users] Re: WMSGetFeatureInfo problem (No results, using OL)

Eichner, Andreas - SID-NLKM Andreas.Eichner at sid.sachsen.de
Wed Jan 27 10:24:38 EST 2010


 
Hi Stella,

according to http://dev.openlayers.org/docs/files/OpenLayers/Control/WMSGetFeatureInfo-js.html the WMSGetFeatureInfo control's constructor takes an array of OpenLayers.Layer.WMS objects. But you give it the list you used to draw as one layer. So you should create two OpenLayers.Layer.WMS objects, one for layer "Test1" and one for "Test2" and then give the control an array of them.
So if I'm correct it should look something like that:

var _test1 = new OpenLayers.Layer.WMS(
                   "MyLayer 1",
                   _mapfilex,
                   {                  
                    layers: [ 'Test1'],
                    format: "image/png",
                    transparent: "true"
                   },
                   {
                    isBaseLayer: false,
                    buffer: 0,
                    visibility: true
                   }
                 );
var _test2 = new OpenLayers.Layer.WMS(
                   "MyLayer 2",
                   _mapfilex,
                   {                  
                    layers: [ 'Test2'],
                    format: "image/png",
                    transparent: "true"
                   },
                   {
                    isBaseLayer: false,
                    buffer: 0,
                    visibility: true
                   }
                 );
var infoCtl = new OpenLayers.Control.WMSGetFeatureInfo({ 
	              layers: Array(_test1, _test2), 
	              title: 'Click on the map to get information on layers', 
	              queryVisible: true, 
	              infoFormat: 'text/html' 
                  }); 
infoCtl.events.register("getfeatureinfo",map,showInfo); 
	
function showInfo(evt) {    
  alert(evt.text);
} 

Also I don't know how MapServer handles queries to two or more layers if at least one of them declares header or footer - it might happen that a layer without a header is processed before one with. And from what you got back I suggest that MapServer processes each layer if it was queried alone and therefore outputs the HTTP "Content-type" header after processing the first layer.

 
Mit freundlichen Grüßen,
 
Andreas Eichner


More information about the mapserver-users mailing list