Error when save feature attribute with Openlayers

المشرف العام

Administrator
طاقم الإدارة
I try OpenLayers.Control.GetFeature to get feature from WFS layer :

function editTool() { var edit = new OpenLayers.Control.GetFeature({ protocol: OpenLayers.Protocol.WFS.fromWMSLayer(Vidagis.CurrentMap.map.layers[1]), click: true, box: true, multipleKey: "shiftKey", toggleKey: "ctrlKey" }, { displayClass: 'pan no-follow', allowDepress: true }); edit.events.register("featureselected", this, function (e) { currentFeature = e.feature; // get the current handler feature changeHtmlForm(storeFeature(e)); unlockUpdate(storeFeature(e).data); $(function () { $("#smalldialog").dialog({ position: { my: 'right', at: 'right' }, maxHeight: 400, maxWidth: 300, autoOpen: false, show: { effect: "blind", duration: 1000 }, hide: { effect: "explode", duration: 1000 } }); $("#smalldialog").dialog("open"); }); }); return edit; // return edit Control }it work fine and i can get feature attributes from featureselected event .now i assign values to currentFeature

currentFeature = e.feature;

Then i write a function to edit currentFeature attributes

// Edit feature attributes function setFeatureAttributes(e) { e.attributes['code_2004'] = 124; return e; }finally , save function

function UpdateFeature() { var feature=setFeatureAttribute(currentFeature); feature.state = OpenLayers.State.UPDATE; saveStrategy.save([feature]); }Declare variable :

var currentFeature; var saveStrategy = new OpenLayers.Strategy.Save();// trigger save event saveStrategy.events.on({ 'success': function (event) { alert('Changes saved'); }, 'fail': function (event) { alert('Error! Changes not saved'); }, scope: this });But when i call UpdateFeature() browser report the error

Uncaught TypeError: Cannot read property 'projection' of null

How can i fix it?



أكثر...
 
أعلى