Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Below is my code which i am using for modifying features and drawing new features.

saveStrategy = new OpenLayers.Strategy.Save();'success', null, ChangesSuccess);'fail', null, ChangesFailed);

wfs = new OpenLayers.Layer.Vector("Edit Vagmitt Polyline", {

    styleMap: StyleMap,
    eventListeners: {
        "featuresadded": ZoomToData
    strategies: [new OpenLayers.Strategy.Fixed(), saveStrategy],
    protocol: new OpenLayers.Protocol.WFS({
        url: GEOSERVER_WFS,
        featureType: "new_Vagmitt_polyline",
        featureNS: "",
        geometryName: "the_geom",
        srsName: "EPSG:900913",
        version: "1.1.0",
        extractAttributes: true,
        isBaseLayer: false,
        visibility: true


new OpenLayers.Control.DrawFeature(wfs, OpenLayers.Handler.Path, {displayClass: 'lineButton', title: 'Draw new line feature', handlerOptions: {style: sty}});

new OpenLayers.Control.ModifyFeature(wfs, {title: 'Edit line feature'}); The code works fine for modifyFeature control, but its gives error on save strategy when i draw a new feature.

The changes are also saved back to Geoserver when i modify the feature (triggers ChangesSuccess). but in case of DrawFeature control, saveStrategy triggers ChangesFailed function.

I could not understand, why ModifyFeature works but DrawFeature does't work. Can anybody explain, where is the problem ?

share|improve this question

Probably you missed to set the feature's state to INSERT. Here is an example code:

var geom = new OpenLayers.Geometry.Point(x, y);
var feature = new OpenLayers.Feature.Vector(geom);
feature.state = OpenLayers.State.INSERT;

See this OpenGeo workshop for a complete example:

share|improve this answer

Can you provide more information about the error when saving a new feature, please?

Also take a look at the response for the initial XHR request of your WFS layer.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.