I have used your code for picking feature info from WMS layer using WMSGetFeatureInfo function. I have used this link. http://underdark.wordpress.com/2011/03/17/picking-a-features-attribute-value-from-a-wms-layer-with-openlayers/ but I can't find the feature info.
feature.length function returns 0.
My WMS layer is:
tiled = new OpenLayers.Layer.WMS(
"unit_project2_ws:unit_project3_view - Tiled",
"http://localhost:8080/geoserver/unit_project2_ws/wms",
{
LAYERS: 'unit_project2_ws:unit_project3',
transparent: true,
STYLES: '',
format: format,
tiled: true,
tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom
},
{
buffer: 0,
displayOutsideMaxExtent: true,
isBaseLayer: false,
yx : {'EPSG:900913' : false}
}
);
........................
Code I have used for the GetFeatureInfo request for the WMS layer:
roadidPicker = new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://localhost:8080/geoserver/unit_project2_ws/wms',>
title: 'identify features on click',
layers: [tiled],
queryVisible: true
});
roadidPicker.infoFormat = 'application/vnd.ogc.gml';
roadidPicker.events.register("getfeatureinfo", this, pickRoadid);
map.addControl(roadidPicker);
roadidPicker.activate();
function pickRoadid(e) {
if (e.features && e.features.length) {
var val = e.features[0].attributes.id;
alert(val);
//document.getElementById('roadId').value = val;
}
else
alert(e.features.length); // this function returns 0 result.
}
What is problem with this code.