Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 3 down vote accepted

In that example you'll see some code like:

        infoControls = {
        click: new OpenLayers.Control.WMSGetFeatureInfo({
            url: '', 
            title: 'Identify features by clicking',
            layers: [water],
            queryVisible: true
        hover: new OpenLayers.Control.WMSGetFeatureInfo({
            url: '', 
            title: 'Identify features by clicking',
            layers: [water],
            hover: true,
            // defining a custom format options here
            formatOptions: {
                typeName: 'water_bodies', 
                featureNS: ''
            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.

share|improve this answer
Yes,It works.Thanks lot for you – sacprasanna Jun 28 '12 at 17:05
And I don't want to all attribute fields of shape file.How I remove some fields from map? – sacprasanna Jun 28 '12 at 18:36

take a look at this post here

Try replace removeLayersOutOfRange() by your raster.


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.