WfsGetFeatureControl,拉框获得多个features

以下是源代码,这个问题搞了我8个小时,郁闷死了。version为1.1.0的wfs服务,默认返回的GML带个节点叫<gml:featureMember s>,所有的format源代码查一遍,调试很久,还是不知道怎么解析,已经准备放弃自己写解析类了。突然想起试下以前的version1.0.0和outputformat:GML2,行了。虽然解决了,还是很郁闷,浪费了这么长的时间啊!!!
trms.GetFeaturesToDeleteVectorLayerControl = OpenLayers.Class(OpenLayers.Control, {

draw: function() {
        this.handler = new OpenLayers.Handler.Box( this,
                            {done: this.zoomBox}, {keyMask: this.keyMask} );
    },
   
    zoomBox: function (position) {
   
        if (position instanceof OpenLayers.Bounds) {
       
            if (!this.out) {
                var minXY = this.map.getLonLatFromPixel(
                            new OpenLayers.Pixel(position.left, position.bottom));
                var maxXY = this.map.getLonLatFromPixel(
                            new OpenLayers.Pixel(position.right, position.top));
                var bounds = new OpenLayers.Bounds(minXY.lon, minXY.lat,
                                               maxXY.lon, maxXY.lat);
            } else {
                var pixWidth = Math.abs(position.right-position.left);
                var pixHeight = Math.abs(position.top-position.bottom);
                var zoomFactor = Math.min((this.map.size.h / pixHeight),
                    (this.map.size.w / pixWidth));
                var extent = this.map.getExtent();
                var center = this.map.getLonLatFromPixel(
                    position.getCenterPixel());
                var xmin = center.lon - (extent.getWidth()/2)*zoomFactor;
                var xmax = center.lon + (extent.getWidth()/2)*zoomFactor;
                var ymin = center.lat - (extent.getHeight()/2)*zoomFactor;
                var ymax = center.lat + (extent.getHeight()/2)*zoomFactor;
                var bounds = new OpenLayers.Bounds(xmin, ymin, xmax, ymax);
            }
           
            var bbox = bounds.left + ',' + bounds.bottom + ',' + bounds.right + ',' + bounds.top;
            var params = {
            service : 'WFS',
version : '1.0.0',
            request : 'GetFeature',
            typeName : 'shane:guandao_renkong,shane:guandao_guandao,shane:ganlu_diangan,shane:ganlu_diaoxian',
            OUTPUTFORMAT : 'GML2',
SRSNAME : 'EPSG:4326',
            BBOX : bbox
            };

            OpenLayers.loadURL("/geoserver/wfs", params, this.map, function(response) {
           
            var g = new OpenLayers.Format.GML();
var features = g.read(response.responseText);

alert(features.length);
            });
        }
    }
});

你可能感兴趣的:(get)