[OpenLayers-Users] Protocol WFS vector layer transform geometry type.

Lucas Heezen - Covadis heezen at covadis.nl
Thu Mar 8 07:56:21 EST 2012


Hello, 

Is it possible to transform the features returned by the Protocol.WFS on a vector layer?
I have in mij database a layer with multipoint geometry. I want the features to be drawn as a point with the rest of the feature attributes.

This is my way to display the features:

this.wfs_layer = new OpenLayers.Layer.Vector("WFS_MODULE_HINDER", {
                strategies: [new OpenLayers.Strategy.BBOX()],
                protocol: new OpenLayers.Protocol.WFS({
                    url: this.service,
                    featureType: this.layer_name.split(":")[1],
                    featureNS: "http://www.openplans.org/topp",
                    geometryName: "geometrie"                    
                }),
                projection: new OpenLayers.Projection("EPSG:28992"),
                displayProjection: new OpenLayers.Projection("EPSG:28992"),                
                //onFeatureInsert: this.onPreFeatureInsert.bind(this)
            }); 

I found something of a protocol.read callback method. 

this.wfs_layer.protocol.read({
//                callback: function(request) {
//                    
//                    var features = [];
//                    
//                    var fts = request.features;
//                    if (fts.length > 0) {
//                        fts.each(function(feature, index) {
//                            
//                            //var mp = new OpenLayers.Geometry.MultiPoint([feature.geometry]);        
//                            var points = feature.geometry.getVertices();
//                            points.each(function(point, index) {
//            
//                                var new_feature = new OpenLayers.Feature.Vector();
//                                new_feature.geometry = point;
//                                new_feature.geometry.transform(map.displayProjection, map.projection);
//                                new_feature.style = style_mark_blue;
//                                                                
//                                features.push(new_feature);
//                            }.bind(this));
//                            
//                        }.bind(this));
//                        
//                        this.wfs_layer.destroyFeatures();
//                        this.wfs_layer.addFeatures(features);
//                    }
//                }.bind(this),
//                scope: this.wfs_layer.strategies[0]
//            })

But the features arend drawn as seperate points and the old features still exists.


More information about the Users mailing list