I got maps like yours working and the only difference that I could spot is that I use OpenLayers.Layer.WMS instead of OpenLayers.Layer.MapServer.
Since GetFeatureInfo is a WMS protocol operation OL correctly should not apply it to Mapserver layers (even though Mapserver is fully capable of speaking WMS).
Try to create the layer as follows:
var wmsmap = new OpenLayers.Layer.WMS( "grib plot",
"/cgi-bin/mapserv.exe?map=wxmap/glmpvis.map",
{layers: 'mosaic',
srs: 'YOUR SRS HERE',
format: 'image/png',
isBaseLayer: false,
visibility: true
}
);
you can do this with some programmatic way as registering map with zoomend
:
eventListeners
{Object} If set as an option at construction, the
eventListeners object will be registered with .
EVENT_TYPES
{Array(String)} Supported application event types. Register a
listener for a particular event with the following syntax:
map.events.register(type, obj, listener);
Listeners will be called with a reference to an event object. The
properties of this event depends on exactly what happened.
Solution Code:
var layer1 = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0",
{layers: 'basic'}, {'displayInLayerSwitcher':false} );
var layer2 = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
"http://t1.hypercube.telascience.org/cgi-bin/landsat7",
{layers: "landsat7"}, {'isBaseLayer': false});
var layer3 = new OpenLayers.Layer.WMS( "DM Solutions Demo",
"http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
{layers: "bathymetry,land_fn,park,drain_fn,drainage," +
"prov_bound,fedlimit,rail,road,popplace",
transparent: "true", format: "image/png" });
layer2.setVisibility(false);
layer3.setVisibility(false);
map.addLayers([layer1, layer2, layer3]);
map.events.register('zoomend', this, function (event) {
var zLevel = map.getZoom();
if( zLevel == 13 || zLevel == 14 || zLevel == 15 )
{
layer2.setVisibility(true);
}
if( zLevel == 16 || zLevel == 17 || zLevel == 18)
{
layer2.setVisibility(false);
layer3.setVisibility(true);
}
});
i hope it helps you...
Best Answer
In that example you'll see some code like:
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.