[GIS] Prevent layer from WMSGetFeatureInfo request on openlayers web map

getfeatureinfoopenlayers-2wms

I use this example code get feature info from my openlayers web map.I add 4 layers to map including raster image as base map.
But i don't need feature info from that raster layer.But when clicking on the map to get information It gives information of all layers.

How I modify above mentioned example code to prevent information from raster layer?

Pls help me,Any idea welcome.Thanks

Best Answer

In that example you'll see some code like:

        infoControls = {
        click: new OpenLayers.Control.WMSGetFeatureInfo({
            url: 'http://demo.opengeo.org/geoserver/wms', 
            title: 'Identify features by clicking',
            layers: [water],
            queryVisible: true
        }),
        hover: new OpenLayers.Control.WMSGetFeatureInfo({
            url: 'http://demo.opengeo.org/geoserver/wms', 
            title: 'Identify features by clicking',
            layers: [water],
            hover: true,
            // defining a custom format options here
            formatOptions: {
                typeName: 'water_bodies', 
                featureNS: 'http://www.openplans.org/topp'
            },
            queryVisible: true
        })
    };

This sets up the getFeatureInfo request on the water layer - you need to modify your code to have just the layer names that you want to query in those spaces. That is don't include your raster layer in that array if you want to exclude it from the request.