[OpenLayers-Users] How to insert that I digitized Feture in my
WFS layer?
Christopher Schmidt
crschmidt at metacarta.com
Wed Nov 19 11:12:44 EST 2008
On Wed, Nov 19, 2008 at 08:02:48AM -0800, ironbar wrote:
>
> I am working with the example vector formats example
> (http://openlayers.org/dev/examples/)
> I created my own wfs layer to which I would like add feature (polygon, line)
> that I digitize on the viewer.
> Now I want to keep most of the script of vector formats example example -
> that is why I want to create function that will create wfs transaction that
> is it will perform wfs insert operation to the layer that I have already
> created.
> So I need function that will perfrom wfs Insert transaction
> Something like this:
>
> function wfs_insrt(feature, wfsl)
> {
> var wff= new OpenLayers.Format.WFS({layerName:'topp:mywfs'},wfsl);
>
> feature.state = OpenLayers.State.INSERT;
>
> wff.insert(feature);
>
> }
No. You don't want to do this.
1. Formats only create strings/DOM elements or Features. They don't
actually save to the server.
2. Formats only expose two API methods -- read and write. You can
probably get a WFS transaction via wff.write([feature]), but that
won't save to the server, only return a string.
3. The WFS Layer already *has* support for this -- simply call
wfsl.commit() to serialize and save to the server.
> So input parameters are the feature and wfs layer and output should be
> executed wfs insert transaction.
OpenLayers does not, at this time, have any methods which you can call
which allow you to pass a feature and execute a WFS insert transaction
-- the way to do this is to add the feature to the layer (as the drawing
tools do automatically) and then call layer.commit().
Regards,
--
Christopher Schmidt
MetaCarta
More information about the Users
mailing list