[OpenLayers-Users] How to insert that I digitized Feture in my WFS layer?

polock joki_frei at yahoo.com
Wed Nov 19 15:06:21 EST 2008


Again and again I receive the error message from the firebug:
An attempt was made to create or change an object in a way which is
incorrect with regard to namespaces" code: "14

var wfsl= new OpenLayers.Layer.WFS( "MY WFS", 
                                           
"http://localhost/geoserver/wfs?", 
                                            {typename: 'topp:mywfs'}, 
                                                       { typename: 
'topp:mywfs'  }); 
wfsl.addFeatures([feature]);
wfsl.commit();

Wherein am I mistaken?



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

-- 
View this message in context: http://www.nabble.com/How-to-insert-that-I-digitized-Feture-in-my-WFS-layer--tp20576678p20588151.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list