[OpenLayers-Users] GetFeatureInfo

eoinyp eoinyp at yahoo.com
Wed Sep 23 10:38:02 EDT 2009


Hi, Im trying to use extract the info on a feature clicked on and display it
below the map in HTML.
I know its a very common task, Ive been following the examples on this list.
Im nearly there except for one small thing - nothing displays for me, i.e no
feature info is returned. Im not sure that it is extracting the correct
info. How does it know which attributes of the feature clicked on to return?
Thanks.
Eoinyp.

Here are some of my code extracts.

//setup a WMS of the Lakes in Ireland:
 var Lakes = new OpenLayers.Layer.WMS(
                    "Irish Lakes", "http://ncg.nuim.ie/geoserver/wms",
                    {
                        layers: 'Lakes_all_2005',
                        styles: '',
                        srs: 'EPSG:29900',        
                        format: format,
                        tiled: 'true',
                        transparent: "true",
                    },
                    {buffer: 1}
                    );



               // support GetFeatureInfo
                map.events.register('click', map, function (e) {
                    document.getElementById('nodelist').innerHTML =
"Loading... please wait...";

                    var url = Lakes.getFullRequestString(

                        {REQUEST: "GetFeatureInfo",
                        EXCEPTIONS: "application/vnd.ogc.se_xml",
                        BBOX: map.getExtent().toBBOX(),
                        X: e.xy.x,
                        Y: e.xy.y,
                        INFO_FORMAT: 'text/html',
                        QUERY_LAYERS: map.layers[5].params.LAYERS,   
//Lakes are in layer 5
                        FEATURE_COUNT: 50,
                        WIDTH: map.size.w,
                        HEIGHT: map.size.h}
                        );
                      

                    //put in an alert for debugging:
 alert("url :"+url); //the message returned by this alert is below.


                    OpenLayers.loadURL(url,'',this, setHTML);

                    OpenLayers.Event.stop(e);
                });

//function to set the HTML

function setHTML(response) {
//debugging                     
alert("setting html response to "+response.responseText);
//the message returned by this alert is blank, i.e. response.responseText
has no value.
      
       OpenLayers.Util.getElement('nodeList').innerHTML =
        response.responseText;}



//The message returned by the first alert is as follows: 

http://ncg.nuim.ie/geoserver/wms?LAYERS=Lakes_all_2005&STYLES=&SRS=EPSG%3A900913&FORMAT=image%2Fpng&TILED=true&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&EXCEPTIONS=application%2Fvnd.ogc.se_xml&BBOX=-1463708.980937%2C6686200.264297%2C-485315.019062%2C7419995.735703&X=351&Y=284&INFO_FORMAT=text%2Fhtml&QUERY_LAYERS=Lakes_all_2005&FEATURE_COUNT=50&WIDTH=800&HEIGHT=600
-- 
View this message in context: http://n2.nabble.com/GetFeatureInfo-tp3700058p3700058.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list