[OpenLayers-Users] Trouble with accessing vector/WFS layer features

cgp carina_palanca at forcorp.com
Mon Dec 21 17:27:36 EST 2009


Thank you for your response Ivan. I tried your suggestion but I'm not sure
when I should call it. Do I call it just before I add it to the map, or just
before I try to access a layer's feature?

I tried calling it just after I added it like this:

                var wfs_layer = new OpenLayers.Layer.Vector("WFS Layer", { 
                        strategies: [ new OpenLayers.Strategy.BBOX(),
saveStrategy], 
                        protocol: new OpenLayers.Protocol.WFS({ 
                                url:  "/geoserver/wfs", 
                                featureType: "user_layer.layer_name", 
                                featureNS: "http://geoserver.sf.net", 
                                featurePrefix: "sde", 
                                srsName: "EPSG:900913", 
                                version: "1.1.0", 
                                geometryName:"SHAPE" 
                        }) 
                });
                wfs_layer.setVisibility(false);
                wfs_layer.strategies[0].triggerRead(); <---calling it right
here
                 map.addLayers([wfs_layer]);

Or 

		var wfs_layer = map.getLayersByName("WFS Layer")[0];
		wfs_layer.strategies[0].triggerRead();

               var layer_features = wfs_layer.features;

But as soon as I try to access the layer with wfs_layer3.features, it gives
a "bounds is null" error. Then, I tried initializing the layer with a bounds
object with new OpenLayers.Strategy.BBOX({bounds:map_bounds}) so that bounds
is not null. But when I do that it makes the browser crash instead.

Any other ideas?


-- 
View this message in context: http://n2.nabble.com/Trouble-with-accessing-vector-WFS-layer-features-tp4189252p4200963.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list