I want to edit object on WFS layer but have one problem. I use OpenLayers.Control.ModifyFeature(myVecLayer)
to editing.By the logic i do this.
- Press button and create WFS layer with chosen object
- Add
OpenLayers.Control.ModifyFeature
to map controls and activate this - Edit object
- Press button again and remove WFS layer with
my object, deactivate
OpenLayers.Control.ModifyFeature
control. Select next object (or same object) and do "1", "2"
And object not editing.
But if I do not remove layer after editing, but just add new WFS layer to mapOpenLayers.Control.ModifyFeature
control works
My code:
function ff(){
if(counter==0){
//WFS
var myStyle = OpenLayers.Util.extend({},
OpenLayers.Feature.Vector.style['default']);
myStyle.strokeWidth = 1.5;
myStyle.strokeColor = "#ff0000";
myStyle.fillOpacity = 0.1;
OpenLayers.ProxyHost = "proxy.cgi?url=";
var renderer = OpenLayers.Util.getParameters(window.location.href).renderer;
renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers;
myVecLayer = new OpenLayers.Layer.Vector("Редактируемый участок", {
strategies: [new OpenLayers.Strategy.BBOX(), new OpenLayers.Strategy.Save()],
style: myStyle,
protocol: new OpenLayers.Protocol.WFS({
version: "1.0.0",
srsName:"EPSG:900913",
url: "http://localhost:8080/geoserver/wfs",
featureType: "filedata",
featureNS: "http://www.opengeospatial.net/cite",
defaultFilter : new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: 'id',
value: "162",
})
}),
renderers: renderer
})
map.addLayers([myVecLayer]);
if(ppp==null){
if (edit==null){
edit = new OpenLayers.Control.ModifyFeature(myVecLayer);
map.addControl(edit);
ppp=map.getControlsByClass("OpenLayers.Control.ModifyFeature");
}
alert(ppp);
}
// ppp.autoActivate=true;
for(var i=0;i<ppp.length;i++){
ppp[i].activate();
alert("2 "+ppp[i].active);
}
counter=1;
}
Its will nice if u help.