THis appears to be due to a synchronisation issue between OpenLayers and a 
Ext.grid.GridPanel loaded with a GeoExt.data.FeatureStore tied to the vector 
layer. I am looking for a way to force an update to the GridPanel when an 
attribute was modified, and was using:

cropStore.unbind(); 
cropStore.bind(crops); 

but this seems to be causing the features to b re-added to the layer, resulting 
in a doubling.

Can anyone suggest how to get GeoExt to re-read the features so the GridPanel 
is updated with the new attributes?

Many thanks,

Robert 

>>> Robert Sanson 24/01/2012 2:29 p.m. >>>
I am using OpenLayers v2.11, and have a vector layer loaded from  geometry in 
WKT format separated from attributes using pipe delimited text from a database 
(via a Python cgi-bin script).

I am trying to write a function that iterates through all of the features and 
then POST updates back to the database when certain conditions are met.
 My difficulty is that layer.features.length is returning double the number of 
features.

Here is my code that creates the layer and loads the features:

function setHTML4cr(response4) {
        var cropnum = 0;
    var lines, line;
    var cropid, name, crds;
    var cropgeom;
    if (response4.responseText.toUpperCase().indexOf('ERROR') != -1) {
      alert(response4.responseText);
    }
    else {
      crops = new OpenLayers.Layer.Vector("Crops",
                  {isBaseLayer: false,
                   styleMap: crop_style,
                   rendererOptions: {zIndexing: true},
                   extractAttributes: true });
      var lines = response4.responseText.split('\n');
      for ( var i=0;i<lines.length;i++) {
        line = lines[i].split("|");
        if ( line.length == 3 ) {
          cropid = line[0];
          name = line[1];
          crds = line[2];
          cropgeom = wkt_format.read(crds);
          cropgeom.attributes.id = cropid;
          cropgeom.attributes.name = name;
          cropgeom.attributes.pstate = "pre";
          crops.addFeatures(cropgeom);
                cropnum = cropnum + 1;
        }
      }
      map.addLayer(crops);
      alert("Crops layer loaded and ready for digitising with " + cropnum + " 
features!");
}

This is reporting the correct number of features, and the features are drawn on 
the map.

However, this function is reporting double the number of features:

function savecrop() {
        var f;
    alert(crops.features.length);
         var allf = [];
    for (i = 0; i < crops.features.length; i++) {
        f = crops.features[i];
        allf.push(f.attributes.id + "|" + f.attributes.name + "|" + 
f.attributes.pstate + "|" + f.state);
    }
    alert(allf.join("\n"));
}

Many thanks,

Robert





This email and any attachments are confidential and intended solely for the 
addressee(s). If you are not the intended recipient, please notify us 
immediately and then delete this email from your system.

This message has been scanned for Malware and Viruses by Websense Hosted 
Security.
www.websense.com
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to