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

Ivan Grcic igrcic at gmail.com
Tue Dec 22 02:27:32 EST 2009


On Mon, Dec 21, 2009 at 11:27 PM, cgp <carina_palanca at forcorp.com> wrote:
>
> 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();
>

 wfs_layer.events.on({
   featuresadded: function(){
        var layer_features = wfs_layer.features;
        ...
        ...
   }
})


cheers
>
>
> 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.
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



-- 
Ivan Grcic



More information about the Users mailing list