[OpenLayers-Users] WFS-T example
Indika Tantrigoda
indika85 at gmail.com
Thu Oct 30 06:48:35 EDT 2008
Hello to all,
I have successfully manged to insert points and a feature attribute to the
database. However the modification/deletes seems to giving some trouble.
Heres the code used.
controls = {
modifylin: new OpenLayers.Control.ModifyFeature(wfs_cities,
modifyOptions,
{'displayClass':
'olControlModifyFeature'}),
dellin: new OpenLayers.Control.SelectFeature(wfs_cities,
modifyOptions)//,
//{'displayClass'
:'olControlModifyFeature'})
};
var modifyOptions = {
onModificationStart: function(feature) {
OpenLayers.Console.log("start modifying",
feature.id);
},
onModification: function(feature) {
OpenLayers.Console.log("modified", feature.id);
},
onModificationEnd: function(feature) {
OpenLayers.Console.log("end modifying", feature.id);
feature.state = OpenLayers.State.UPDATE;
//alert("Hello");
},
onDelete: function(feature) {
OpenLayers.Console.log("delete", feature.id);
},
onSelect: function(feature){
OpenLayers.Console.log("select", feature.id);
feature.state = OpenLayers.State.DELETE;
}
};
The point can be moved within the map, and the commented alert also gets
executed. However when I refresh the page
the point is still at the initial location.
Anything I am missing ?
Thanks in advance,
Indika
2008/7/18 Indika Tantrigoda <indika85 at gmail.com>
> Thanks guys, appreciate this very much.
>
> Regards,
> Indika
>
> 2008/7/17 Fabio D'Ovidio <fabiodovidio at gmail.com>:
>
> Here are samples using WFS-T and GeoServer.
>> You can draw, modify and delete features (e.g. lines).
>> 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.
>> 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..
>>
>> Hope this help!
>>
>> map = new OpenLayers.Map( 'map' ,
>> { controls: [] , 'numZoomLevels':19});
>> ol_wms = new OpenLayers.Layer.WMS( "OpenLayers
>> WMS",
>> "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}
>> );
>>
>> var linea = new OpenLayers.Layer.WFS(
>> "Elementi lineari",
>> "/geoserver/wfs",
>> {typename: 'topp:linea'},
>> {
>> typename: 'linea',
>> featureNS: 'http://www.openplans.org/topp',
>> extractAttributes: false
>> }
>> );
>> if (!linea.writer) {
>> poligono.writer = new
>> OpenLayers.Format.WFS({layerName:'topp:linea'},linea);
>> }
>> linea.style.strokeColor = "#0000ff";
>>
>> map.addLayers([ol_wms, linea]);
>>
>>
>> var panel = new OpenLayers.Control.Panel(
>> {displayClass: 'olControlEditingToolbar'}
>> );
>> var drawLine = new OpenLayers.Control.DrawFeature(
>> linea, OpenLayers.Handler.Path,
>> {displayClass: 'olControlDrawFeaturePath'}
>> );
>> drawLine.featureAdded = function(feature) {
>> feature.layer.eraseFeatures([feature]);
>> // cast to multilinestring
>> feature.geometry = new OpenLayers.Geometry.MultiLineString(
>> feature.geometry
>> );
>> feature.style.strokeColor = "#ff0000";
>> feature.style.strokeWidth = "5";
>> feature.style.strokeOpacity = "0.75";
>> feature.state = OpenLayers.State.INSERT;
>> feature.layer.drawFeature(feature);
>> }
>>
>> var modifyOptions = {
>> onModificationStart: function(feature) {
>> OpenLayers.Console.log("start modifying", feature.id);
>> },
>> onModification: function(feature) {
>> OpenLayers.Console.log("modified", feature.id);
>> },
>> onModificationEnd: function(feature) {
>> OpenLayers.Console.log("end modifying", feature.id);
>> feature.state = OpenLayers.State.UPDATE;
>> },
>> onDelete: function(feature) {
>> OpenLayers.Console.log("delete", feature.id);
>> },
>> onSelect: function(feature){
>> OpenLayers.Console.log("select", feature.id);
>> feature.state = OpenLayers.State.DELETE;
>> }
>> };
>> controls = {
>> dellin: new
>> OpenLayers.Control.SelectFeature(linea,
>> modifyOptions),
>> modifylin: new OpenLayers.Control.ModifyFeature(linea,
>> modifyOptions)
>>
>> };
>> for(var key in controls) {
>> map.addControl(controls[key]);
>> }
>>
>> document.getElementById('noneToggle').checked = true;
>> panel.addControls(
>> [new OpenLayers.Control.Navigation(), drawLine]
>> );
>> map.addControl(panel);
>> map.addControl(new OpenLayers.Control.LayerSwitcher());
>> map.addControl(new OpenLayers.Control.MouseDefaults());
>> map.addControl(new OpenLayers.Control.MousePosition());
>> map.addControl(new OpenLayers.Control.PanZoomBar());
>> map.zoomToExtent();
>>
>> }
>>
>> function toggleControl(element) {
>> for(key in controls) {
>> var control = controls[key];
>> if(element.value == key && element.checked) {
>> control.activate();
>> } else {
>> control.deactivate();
>> }
>> }
>> }
>>
>>
>> --
>> Ing. Fabio D'Ovidio
>>
>> INOVA Open Solutions s.r.l.
>> Web : http://www.inovaos.it
>> Tel.: 081 197 57 600
>> mail: fabiodovidio at gmail.com
>>
>>
>> Alexandre Dubé ha scritto:
>>
>>> Hi Fabio,
>>>
>>> That would be most appreciated. Indika is also looking forward to see
>>> an example to get wfs-t features working.
>>>
>>>
>>> Fabio D'Ovidio wrote:
>>>
>>>> If u want,
>>>> I developed something like taht some times ago ...
>>>>
>>>> Alexandre Dubé ha scritto:
>>>>
>>>>> Hi everyone,
>>>>>
>>>>> 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.
>>>>>
>>>>> Thanks,
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20081030/116863dc/attachment.html
More information about the Users
mailing list