[OpenLayers-Users] Adding Feature to WFS in Vector Layer / Copying
Features
Fabian Patzke
patzke at geoinformationsdienst.de
Wed Aug 5 07:15:21 EDT 2009
Hi list,
I try to build a copy function so that a user can select some features from a
WFS and copy them to another.
My WFS are not normal WFS Layers they are build in Vector Layers
wfsLayer [layerArray[j].name] = new OpenLayers.Layer.Vector (
...
{
strategies: [
new OpenLayers.Strategy.Fixed({preload:false}),
new OpenLayers.Strategy.Save({
...
],
projection: new OpenLayers.Projection("EPSG:31467"),
protocol: new OpenLayers.Protocol.WFS({...})
},
...
);
I made a function to select features from a WFS, these features are temporarily
stored in a normal Vector layer ("select"). This function is build after:
http://www.openlayers.org/dev/examples/getfeature-wfs.html
Another function is called after the end of selecting features, the user has to
end selecting manually. This should be the copy function. The function should
take all features from the "select" layer and copy them over to the wfsLayer
from above.
That is all I have so far:
function copySelectedFeatures (wfsLayer){
features = select.features;
for (i=0;i<features.length;i++){
var feature = features[i];
layer.addFeatures([feature]);
layer.strategies[1].save(feature);
}
}
Is this the correct approach, I have included the line:
layer.strategies[1].save(feature);
because I thought it would commit newly added features, but it wont work. No
feature is ever added.
Any help is welcome :)
Thanks in forward.
Greetings,
Fabian
More information about the Users
mailing list