I have a map with a WFS-Layer and I am able to add Polygons to my data stored in a PostGIS-database, served with GeoServer (OpenLayers, GeoServer 2.1.4, PostGIS 2.0 for PostgreSQL 9.1).)
How can I add a description to the polygon? E.g., after drawing a polygon I want to specify the crop that are grown there, i.e. insert information into the Postgis-table-column "crop".
I found this example:
http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/styles_unique_with_group_wfs.html.
The Popup type "edit name and description" would be perfect for my means, unfortunately I can't work out how it works as I have a really hard time understanding its code, greenhorn that I am...
- How is it done?
- Or is there an easier example/ way of how to use a popup to edit your attributes?
Here's my WFS-Layer and the tools used so far. The desired column to edit/add Information in the postgis-table "test" is "crop".
function init() {
Save-strategy
var saveStrategy = new OpenLayers.Strategy.Save();
//empty map, bounds are test-layer bounds (EPSG:32647)
map = new OpenLayers.Map({
div: "map",
allOverlays: true,
maxExtent: new OpenLayers.Bounds(
653237.69439077,1519879.063165,655229.57939001,1520825.6733868
)
});
//WFS-Layer Test= editable data
var test = new OpenLayers.Layer.Vector("Editable Features", {
strategies: [new OpenLayers.Strategy.Fixed(), saveStrategy],
protocol: new OpenLayers.Protocol.WFS({
url: "http://..../wfs",
featurePrefix: 'testkf',
featureNS: "http://.../testkf",
extractAttributes: true,
featureType: "test",
geometryName: "geom",
})
});
map.addLayer(test);
//Toolbar:
var panel = new OpenLayers.Control.Panel(
{'displayClass': 'customEditingToolbar'}
);
var draw = new OpenLayers.Control.DrawFeature(
test, OpenLayers.Handler.Polygon,
{
title: "Draw Feature",
displayClass: "olControlDrawFeaturePolygon",
multi: true
});
var save = new OpenLayers.Control.Button({
title: "Save Changes",
trigger: function() {
if(edit.feature) {
edit.selectControl.unselectAll();
}
saveStrategy.save();
},
displayClass: "olControlSaveFeatures"
});
panel.addControls([save, draw]);
map.addControl(panel);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();
}
EDIT:
So nobody knows anything about this topic or is there another problem with my question? I found another example, however, this is way too complex for me to understand yet: http://dev4.mapgears.com/bdga/bdgaWFS-T.html
This is exactly what I am looking for. Can anyone break it down to me what the steps are to achieve this?
Or is there any way to improve my question?