Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have used your code for picking feature info from wms layer using WMSGetFeatureInofo function.I have used you this link. http://underdark.wordpress.com/2011/03/17/picking-a-features-attribute-value-from-a-wms-layer-with-openlayers/ but I cant found 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 to get feature info from 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.

share|improve this question
    
Can u please provide the working code... –  user14362 Jan 18 '13 at 9:51
add comment

1 Answer

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.

share|improve this answer
    
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 Sep 19 '12 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 Sep 19 '12 at 14:00
add comment

Your Answer

 
discard

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.