[OpenLayers-Users] How to use WMSGetFeatureInfo to get features and add it to map?

ahwangyuwei at sina.com ahwangyuwei at sina.com
Wed Apr 7 21:50:26 EDT 2010


 I'm using WMSGetFeatureInfo to get Featureinfo.
How can I get Feature from the WMSGetFeatureInfo 's response?
And add them to map?
I am imitating the Control OpenLayers.Control.WMSGetFeatureInfo's bahavior.
It's available?

 map.events.register('click', map, function (e) {
                    document.getElementById('nodelist').innerHTML = "Loading... please wait...";
                    var params = {
                        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[0].params.LAYERS,
                        FEATURE_COUNT: 50,
                        Layers: 'CHN',
                        Styles: '',
                        Srs: 'EPSG:4326',
                        WIDTH: map.size.w,
                        HEIGHT: map.size.h,
                        format: format};
                    updateFeatureInfoFilters(params);
                    OpenLayers.loadURL("http://159.226.13.203:8080/geoserver/wms", params, this, setHTML, setHTMLx);
                    OpenLayers.Event.stop(e);
                });
            }
 var parseformat= new OpenLayers.Format.WMSGetFeatureInfo();
function setHTML(response){
       document.getElementById('nodelist').innerHTML = response.responseText;
                
             var doc = response.responseXML;
            if(!doc || !doc.documentElement) {
               doc = response.responseText;
             }
           
            var features = parseformat.read(doc);
            highlightLayer.addFeatures(features);

            
            };

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100408/b9f4afc2/attachment.html


More information about the Users mailing list