[GIS] Query Feature using OpenLayers + MapServer

mapserveropenlayers-2query

I'm trying to query a feature in OpenLayers, but it's returning just an image highlighted that is not possible to make zoom, pan and drag.

My intention is to query a feature on the map like street name, city and country. Is there any function in OpenLayers?

I'm using this code:

var query = new OpenLayers.Layer.WMS( "Utbs", 
    "http://localhost/cgi-bin/wms.exe", 
    {
    srs: 'EPSG:4326',
    width: '800',
    styles: '',
    height: '600',
    layers: 'layer_name',   
    mode: 'itemquerymap',
    qstring: "(value = '03')",
    qlayer: 'layer_name',
    mapxy: 'shape'  
    },
    {
    singleTile: true    
    }
);

map.addLayers([utbs_query]);
map.zoomToMaxExtent();

Best Answer

Take a look at the Feature Info example for OpenLayers.

This uses the GetFeatureInfo requests for WMS layers to return attribute data. You may have to modify your WMS configuration in MapServer or GeoServer (or whatever is serving your WMS layers) to support this.