[OpenLayers-Users] Adding new features: WFS-T PostGIS

Gabriel Nolasco nolasco_gabriel at yahoo.com.br
Fri Aug 21 07:23:26 EDT 2009


Hi,

To set a feature attributes use the property 'attributes' from the class 'OpenLayers.Feature.Vector'.
You can control the type of the transaction doing something like:

if (selectedFeature.state != OpenLayers.State.INSERT) {
    selectedFeature.state = OpenLayers.State.UPDATE;
}

Some examples:
http://demo.mapfish.org/mapfishsample/trunk/examples/editing/editing-panel.html
http://dev4.mapgears.com/bdga-fs/

Good work!

Gabriel Nolasco

> 
> Hi all,
> 
> In case that someone is stuck with the same problem that I
> had I attached
> the code that works for me.
> 
> By the way, Can anyone point me to some examples using a
> web form to enter
> and modify attributes store in a PostGIS DB via WFS-T?
> 
> Thanks for your help!
> 
> 
> //WFS Layer
> 
> wfs3 = new OpenLayers.Layer.WFS(
>                
> "Same Water Points",
>                 "http://localhost:8080/geoserver/wfs",
>                
> {typename: 'cite:water_points'},
>                 {
>                
>     typename: "water_points",
>                
>     featureNS: "http://www.opengeospatial.net/cite",
>                
>     extractAttributes: false,
>                
>     commitReport: function(str) {
>                
>         OpenLayers.Console.log(str);
>                
>     }
>                 }
>             );
>     
>         var saveStrategy =
> new OpenLayers.Strategy.Save({ 
>        callback: function() { 
>        
>    alert('feature saved'); 
>        } 
>    }); 
>     
> map.addLayers([wfs3]);
> 
> 
> //BUTTONS:
> 
> var panel = new OpenLayers.Control.Panel({
>                
> displayClass: "olControlEditingToolbar"
>             });
>             
>             var draw = new
> OpenLayers.Control.DrawFeature(
>                
> wfs3, OpenLayers.Handler.Point,
>                 {
>                
>     handlerOptions: {freehand: false, multi:
> true},
>                
>     displayClass: "olControlDrawFeaturePoint"
>                 }
>             );
>             
>            
> var modify = new OpenLayers.Control.ModifyFeature(wfs3, {
>                
> title: "Modify Feature",
>            
>     displayClass: "olControlModifyFeature"
>            
>     });
>                 
>        
>      var del = new
> DeleteFeature(wfs3, {title: "Delete Feature"});
>     
>            
>     
>        
>      var save = new
> OpenLayers.Control.Button({
>                
> trigger: OpenLayers.Function.bind(wfs3.commit, wfs3),
>                
> displayClass: "olControlEditingToolbar",
>            
>     title: "Guardar"
>             });
> 
>             
>            
>        
>            
> panel.addControls([
>                 new
> OpenLayers.Control.Navigation(),
>                
> save, del, modify, draw
>             ]);
> 
>            
> map.addControl(panel);
>



      ____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com



More information about the Users mailing list