Hi Neelima,<div><br></div><div> I'm not sure if anyone got back to you yet, but I'm guessing the issue here might be that you need to configure your MapServer for WFS-T, and not just WFS. I'm not sure if you've done that step already, but I think MapServer does not support transactional WFS (saving) out of the box. Instead you want to configure something like TinyOWS alongside MapServer to do the saving to PostGIS for you.</div>
<div><br></div><div>You can see more on configuring MapServer to do this here:</div><div><a href="http://mapserver.org/trunk/tinyows/openlayershowtotransactional.html">http://mapserver.org/trunk/tinyows/openlayershowtotransactional.html</a> </div>
<div><br></div><div>and there is a WFS-T example of OpenLayers here:</div><div><a href="http://openlayers.org/dev/examples/wfs-protocol-transactions.html">http://openlayers.org/dev/examples/wfs-protocol-transactions.html</a> <br>
<br>I suspect your question might be better directed at one of the MapServer or TinyOWS mailing lists, or at the OpenLayers Users mailing list.</div><div><br></div><div>Thanks,</div><div>David</div><div><br><br><div class="gmail_quote">
On Tue, Feb 14, 2012 at 6:31 AM, Neelima Emmani <span dir="ltr"><<a href="mailto:neelima.emmani@iictechnologies.com">neelima.emmani@iictechnologies.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">Hi All,
<br>
<br>
In openlayers, I have a map with google layer and over that I am overlaying POSTGIS data as a WFS overlay. For this I am also using OpenLayers Editing tools, all the editing tools are working fine (drawpoint, line, modify, delete) except SAVE Button. When
i say, SAVE it is showing me save failure alert message. Can any one suggest me how to mak eit success.
<br>
My piece of code is as follows in .js file -<br>
<br>
var map;<br>
<br>
function init() {<br>
map = new OpenLayers.Map("map");<br>
<br>
//GOOGLE MAP<br>
var base = new OpenLayers.Layer.Google("Google Hybrid", {'type': G_HYBRID_MAP});
<br>
map.addLayer(base); <br>
<br>
//VECTOR LAYER FOR PANEL<br>
var vlayer = new OpenLayers.Layer.Vector("vlayer");<br>
map.addLayer(vlayer); <br>
<br>
// CREATE WFSLAYERS<br>
<br>
//SAVE STRATEGY<br>
var saveStrategy = new OpenLayers.Strategy.Save();<br>
saveStrategy.events.register('start', null, saveStart);<br>
saveStrategy.events.register('success', null, saveSuccess);<br>
saveStrategy.events.register('fail', null, saveFail);<br>
<br>
//style map for points<br>
var styleMap = new OpenLayers.StyleMap(OpenLayers.Util.applyDefaults({fillColor: "CYAN", fillOpacity: 1, strokeColor: "black"},<br>
OpenLayers.Feature.Vector.style["default"]));<br>
<br>
// mock up a protocol for synchronous and successful commits<br>
var wfs_protocol = new OpenLayers.Protocol.WFS({url:"<a href="http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/apps/openlayers-2.10/examples/addline.map&SERVICE=WFS&VERSION=1.0.0&REQUEST=getfeature&TYPENAME=xxx" target="_blank">http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/apps/openlayers-2.10/examples/addline.map&SERVICE=WFS&VERSION=1.0.0&REQUEST=getfeature&TYPENAME=xxx</a>",
<br>
featureType: "us1gc09m", <br>
srsName: "EPSG:900913"}); <br>
<br>
var wfslayer = new OpenLayers.Layer.Vector("WFS", {styleMap: styleMap, strategies: [new OpenLayers.Strategy.Fixed(), saveStrategy], protocol: wfs_protocol});<br>
<br>
map.addLayer(wfslayer);<br>
<br>
//PANEL DEFINITION<br>
var panel = new OpenLayers.Control.Panel(<br>
{'displayClass': 'customEditingToolbar'}<br>
);<br>
<br>
var navigate = new OpenLayers.Control.Navigation({<br>
title: "Pan Map"<br>
});<br>
<br>
var drawpath = new OpenLayers.Control.DrawFeature(<br>
wfslayer, OpenLayers.Handler.Path,<br>
{<br>
title: "Draw Path",<br>
displayClass: "olControlDrawFeaturePath",<br>
multi: true<br>
}<br>
);<br>
<br>
var drawpoint = new OpenLayers.Control.DrawFeature(<br>
wfslayer, OpenLayers.Handler.Point,<br>
{<br>
title: "Add Point",<br>
displayClass: "olControlDrawFeaturePoint",<br>
multi: true<br>
}<br>
); <br>
<br>
//ADD POINT TO LAYER<br>
drawpoint.featureAdded = function(feature) { <br>
alert("draw point: " + feature.geometry);<br>
// cast to multipoint<br>
feature.geometry = new OpenLayers.Geometry.MultiPoint(<br>
feature.geometry<br>
); <br>
<br>
feature.state == OpenLayers.State.INSERT; <br>
this.layer.drawFeature(feature);<br>
saveStrategy.save(feature);<br>
};<br>
var edit = new OpenLayers.Control.ModifyFeature(wfslayer, {<br>
title: "Modify Feature",<br>
displayClass: "olControlModifyFeature"<br>
});<br>
<br>
//delete feature definition<br>
var DeleteFeature = OpenLayers.Class(OpenLayers.Control, {<br>
initialize: function(layer, options) {<br>
OpenLayers.Control.prototype.initialize.apply(this, [options]);<br>
this.layer = layer;<br>
this.handler = new OpenLayers.Handler.Feature(<br>
this, layer, {click: this.clickFeature}<br>
);<br>
},<br>
clickFeature: function(feature) {<br>
// if feature doesn't have a fid, destroy it<br>
if(feature.fid == undefined) {<br>
this.layer.destroyFeatures([feature]);<br>
} else {<br>
feature.state = OpenLayers.State.DELETE;<br>
this.layer.events.triggerEvent("afterfeaturemodified", {feature: feature});<br>
feature.renderIntent = "select";<br>
this.layer.drawFeature(feature);<br>
}<br>
},<br>
setMap: function(map) {<br>
this.handler.setMap(map);<br>
OpenLayers.Control.prototype.setMap.apply(this, arguments);<br>
},<br>
CLASS_NAME: "OpenLayers.Control.DeleteFeature"<br>
});<br>
<br>
var del = new DeleteFeature(wfslayer, {title: "Delete Feature"});
<br>
<br>
var save = new OpenLayers.Control.Button({<br>
title: "Save Changes",<br>
trigger: function() {<br>
if(edit.feature) {<br>
edit.selectControl.unselectAll();<br>
}<br>
saveStrategy.save();<br>
},<br>
displayClass: "olControlSaveFeatures"<br>
});<br>
<br>
<br>
panel.addControls([navigate, save, del, edit, drawpoint, drawpath]);
<br>
panel.defaultControl = navigate;<br>
<br>
map.addControl(panel);<br>
map.addControl(new OpenLayers.Control.MousePosition());<br>
map.addControl(new OpenLayers.Control.LayerSwitcher());<br>
map.zoomToMaxExtent();<br>
map.setCenter(new OpenLayers.LonLat(-82, 28),5);<br>
}<br>
<br>
//SAVESTART EVENT<br>
function saveStart(event) {<br>
alert('save layer start'); <br>
}<br>
<br>
//SAVESUCCESS EVENT<br>
function saveSuccess(event) {<br>
alert('Changes saved'); <br>
}<br>
<br>
//SAVEFAIL EVENT<br>
function saveFail(event) {<br>
alert('Error! Changes not saved');<br>
}<br>
<br>
<br>
<br>
<br>
<br>
Eagerly waiting for reply and suggestions.
<div><br>
<div style="font-family:Tahoma;font-size:13px">With Regards,<br><font color="#888888">
Neelima Emmani<br>
</font></div>
</div>
</div>
</div>
<br>_______________________________________________<br>
Dev mailing list<br>
<a href="mailto:Dev@lists.osgeo.org">Dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>David Middlecamp, Software Developer<br><br>Azavea | 340 N 12th St, Ste 402, Philadelphia, PA<br><a href="mailto:dmiddlecamp@azavea.com" target="_blank">dmiddlecamp@azavea.com</a> | T 215.701.7688 | F 215.925.2663<br>
Web <a href="http://azavea.com" target="_blank">azavea.com</a> | Blog <a href="http://azavea.com/blogs" target="_blank">azavea.com/blogs</a> | @dmiddlecamp<br>
</div>