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.
-
Can u please provide the working code...user14362– user143622013年01月18日 09:51:38 +00:00Commented Jan 18, 2013 at 9:51
1 Answer 1
I would get rid of those html
tags in your code. I really do not know if that is your problem but I have never seen that.
-
oh,sory,tags have been removed now,that was my negligency,Problem is code else than html tags,Now check the code and answer me.Aftab Ahamad– Aftab Ahamad2012年09月19日 05:13:01 +00:00Commented Sep 19, 2012 at 5:13
-
I dropped the WMSGetFeatureInfo code and the pickRoadid function into a map and they worked for me on a wms layer. I had a featurelength. What happens when you change your url to localhost:8080/geoserver/wms'?Ralph Dell– Ralph Dell2012年09月19日 14:00:12 +00:00Commented Sep 19, 2012 at 14:00