Hello to all,<br>I have successfully manged to insert points and a feature attribute to the database. However the modification/deletes seems to giving some trouble.<br><br>Heres the code used.<br><br>controls = {<br> modifylin: new OpenLayers.Control.ModifyFeature(wfs_cities,<br>
modifyOptions,<br> {'displayClass': 'olControlModifyFeature'}),<br> <br> dellin: new OpenLayers.Control.SelectFeature(wfs_cities,<br>
modifyOptions)//,<br> //{'displayClass' :'olControlModifyFeature'}) <br> };<br>
<br>var modifyOptions = {<br> onModificationStart: function(feature) {<br> OpenLayers.Console.log("start modifying", <a href="http://feature.id">feature.id</a>); <br>
},<br> onModification: function(feature) {<br> OpenLayers.Console.log("modified", <a href="http://feature.id">feature.id</a>); <br> },<br>
onModificationEnd: function(feature) {<br> OpenLayers.Console.log("end modifying", <a href="http://feature.id">feature.id</a>);<br> <br> feature.state = OpenLayers.State.UPDATE; <br>
<br> //alert("Hello");<br> },<br> onDelete: function(feature) {<br> OpenLayers.Console.log("delete", <a href="http://feature.id">feature.id</a>); <br>
},<br> onSelect: function(feature){<br> OpenLayers.Console.log("select", <a href="http://feature.id">feature.id</a>); <br> feature.state = OpenLayers.State.DELETE;<br>
}<br> };<br><br>The point can be moved within the map, and the commented alert also gets executed. However when I refresh the page<br>the point is still at the initial location. <br><br>Anything I am missing ?<br>
<br>Thanks in advance,<br>Indika<br><br><br><br><div class="gmail_quote">2008/7/18 Indika Tantrigoda <span dir="ltr"><<a href="mailto:indika85@gmail.com">indika85@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">Thanks guys, appreciate this very much.<br><br>Regards,<br>Indika<br><br><div class="gmail_quote">2008/7/17 Fabio D'Ovidio <<a href="mailto:fabiodovidio@gmail.com" target="_blank">fabiodovidio@gmail.com</a>>:<div>
<div></div><div class="Wj3C7c"><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Here are samples using WFS-T and GeoServer.<br>
You can draw, modify and delete features (e.g. lines).<br>
I developed it for points, polygons, too and I have added FILTER on WFS requests passing a value in query string, configured also WMS GetFeatureInfo in order to query my WFS data on click.<br>
Now I am developing a module to create dinamically GeoRSS (including GML as geometries) by querying these features in geoserver as WFS Service and fill them with different colours respect some attribute values..<br>
<br>
Hope this help!<br>
<br>
map = new OpenLayers.Map( 'map' ,<br>
{ controls: [] , 'numZoomLevels':19});<br>
ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",<br>
"<a href="http://labs.metacarta.com/wms/vmap0" target="_blank">http://labs.metacarta.com/wms/vmap0</a>?", {layers: 'basic'}<br>
);<br>
<br>
var linea = new OpenLayers.Layer.WFS(<br>
"Elementi lineari",<br>
"/geoserver/wfs",<br>
{typename: 'topp:linea'},<br>
{<br>
typename: 'linea',<br>
featureNS: '<a href="http://www.openplans.org/topp" target="_blank">http://www.openplans.org/topp</a>',<br>
extractAttributes: false<br>
}<br>
);<br>
if (!linea.writer) {<br>
poligono.writer = new<br>
OpenLayers.Format.WFS({layerName:'topp:linea'},linea);<br>
}<br>
linea.style.strokeColor = "#0000ff";<br>
<br>
map.addLayers([ol_wms, linea]);<br>
<br>
<br>
var panel = new OpenLayers.Control.Panel(<br>
{displayClass: 'olControlEditingToolbar'}<br>
);<br>
var drawLine = new OpenLayers.Control.DrawFeature(<br>
linea, OpenLayers.Handler.Path,<br>
{displayClass: 'olControlDrawFeaturePath'}<br>
);<br>
drawLine.featureAdded = function(feature) {<br>
feature.layer.eraseFeatures([feature]);<br>
// cast to multilinestring<br>
feature.geometry = new OpenLayers.Geometry.MultiLineString(<br>
feature.geometry<br>
);<br>
feature.style.strokeColor = "#ff0000";<br>
feature.style.strokeWidth = "5";<br>
feature.style.strokeOpacity = "0.75";<br>
feature.state = OpenLayers.State.INSERT;<br>
feature.layer.drawFeature(feature);<br>
}<br>
<br>
var modifyOptions = {<br>
onModificationStart: function(feature) {<br>
OpenLayers.Console.log("start modifying", <a href="http://feature.id" target="_blank">feature.id</a>);<br>
},<br>
onModification: function(feature) {<br>
OpenLayers.Console.log("modified", <a href="http://feature.id" target="_blank">feature.id</a>);<br>
},<br>
onModificationEnd: function(feature) {<br>
OpenLayers.Console.log("end modifying", <a href="http://feature.id" target="_blank">feature.id</a>);<div><br>
feature.state = OpenLayers.State.UPDATE;<br></div>
},<br>
onDelete: function(feature) {<br>
OpenLayers.Console.log("delete", <a href="http://feature.id" target="_blank">feature.id</a>); },<br>
onSelect: function(feature){<br>
OpenLayers.Console.log("select", <a href="http://feature.id" target="_blank">feature.id</a>); feature.state = OpenLayers.State.DELETE;<br>
}<br>
};<br>
controls = {<br>
dellin: new OpenLayers.Control.SelectFeature(linea,<br>
modifyOptions),<br>
modifylin: new OpenLayers.Control.ModifyFeature(linea,<br>
modifyOptions)<br>
};<br>
for(var key in controls) {<br>
map.addControl(controls[key]);<br>
}<br>
document.getElementById('noneToggle').checked = true;<br>
panel.addControls(<br>
[new OpenLayers.Control.Navigation(), drawLine]<br>
);<br>
map.addControl(panel);<br>
map.addControl(new OpenLayers.Control.LayerSwitcher());<br>
map.addControl(new OpenLayers.Control.MouseDefaults());<br>
map.addControl(new OpenLayers.Control.MousePosition());<br>
map.addControl(new OpenLayers.Control.PanZoomBar());<br>
map.zoomToExtent();<br>
<br>
}<br>
<br>
function toggleControl(element) {<br>
for(key in controls) {<br>
var control = controls[key];<br>
if(element.value == key && element.checked) {<br>
control.activate();<br>
} else {<br>
control.deactivate();<div><br>
}<br>
}<br>
}<br>
<br>
<br>
-- <br>
Ing. Fabio D'Ovidio<br>
<br>
INOVA Open Solutions s.r.l.<br>
Web : <a href="http://www.inovaos.it" target="_blank">http://www.inovaos.it</a><br>
Tel.: 081 197 57 600<br>
mail: <a href="mailto:fabiodovidio@gmail.com" target="_blank">fabiodovidio@gmail.com</a><br>
<br>
<br></div><div><div></div><div>
Alexandre Dubé ha scritto:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Fabio,<br>
<br>
That would be most appreciated. Indika is also looking forward to see an example to get wfs-t features working.<br>
<br>
<br>
Fabio D'Ovidio wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
If u want,<br>
I developed something like taht some times ago ...<br>
<br>
Alexandre Dubé ha scritto:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi everyone,<br>
<br>
Does anybody have a WFS-T example to share ? I would like to see how to use a WFS layer, modify it and post my changes to a WFS server.<br>
<br>
Thanks,<br>
<br>
<br>
</blockquote>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
</div></div></blockquote></div></div></div><br></div>
</blockquote></div><br>