[OpenLayers-Dev] Able to delete/ move feature and save it without problems, but upon refreshing the data, it is the same as before the delete/ move.

Sunder Raj Abbai Naidoo SunderRajA at sita.co.za
Sun Mar 8 10:57:49 EDT 2009


Good Day Everyone

I am busy working on a project that requires a feature to be added, moved and deleted.  The "add feature" functionality works i.e. able to add a feature, save it and upon refresh the feature is displayed. The "move feature" functionality is able to move a feature and save without any bugs, but upon refreshing the data the feature is in the old location. The "delete feature" functionality is able to delete a feature and save without any bugs, but upon refreshing the data the feature is displayed. Below is the coding that I am using. Your help is appreciated.

Definition of WFS
var cities = new OpenLayers.Layer.WFS(
    "Cities",
    "http://10.128.78.27:8080/geoserver/wfs",
    {typename: topp:tasmania_cities'},
    {featureNS: http://www.openplans.org/topp',
     extractAttributes: true});
cities.style = OpenLayers.Util.applyDefaults({strokeColor: "#0000ff"}, 
               OpenLayers.Feature.Vector.style["default"]);

Defination of Add, Edit, Del, Save.

function deleteFeature(geometry)
{
  this.state = OpenLayers.State.DELETE;
  this.layer.removeFeatures(geometry);
  this.renderIntent = "select";
}

var drawPoint = new OpenLayers.Control.DrawFeature(
                    cities, OpenLayers.Handler.Point,
                   {displayClass: 'olControlAddFeaturePoint'});
drawPoint.featureAdded = function(feature) {
  feature.layer.eraseFeatures([feature]);
  // cast to point
  feature.geometry = new OpenLayers.Geometry.MultiPoint(feature.geometry);
  feature.style.strokeColor = "#0000ff";
  feature.state = OpenLayers.State.INSERT;
  feature.layer.drawFeature(feature);
}

var edit = new OpenLayers.Control.ModifyFeature(cities, 
    {title: "Modify Feature", 
     displayClass: "olControlModifyFeature"});

var save  = new OpenLayers.Control.Button(
    {title: "Save Changes",
     trigger: OpenLayers.Function.bind(cities.commit, cities),
     displayClass: "olControlSaveFeatures"});

var del = new OpenLayers.Control.SelectFeature(cities,
    {title: "Delete Feature",
     onSelect: deleteFeature,
     displayClass: "olControlDeleteFeature"});


Kind Regards,
 
Sunder Raj Abbai Naidoo
Specialist: Analyst Programmer
IT Consulting; Solution Delivery                           
+27 (0)12 470 1584 (Office)
+27 (0)12 470 1456 (Fax)
+27 (0)83 461 3397 (Mobile)



.



More information about the Dev mailing list