Monday, 29 July 2019

wfs - How to edit feature attributes with openlayers?


I want to edit object's attributes on WFS layer. I see this example http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/styles_unique_with_group_wfs.html but popup is horrible. I want to use ExtJs form to editing.
So how to edit attributes in this case?



Answer




At first need to create store


                          st = new GeoExt.data.FeatureStore({
layer: myVecLayer,
fields: [
{name: 'id', type: 'int'}
],
proxy: new GeoExt.data.ProtocolProxy({
protocol: new OpenLayers.Protocol.WFS({
version: "1.0.0",
srsName:"EPSG:900913",

url: "http://localhost:8080/geoserver/wfs",
featureType: "filedata_temp",
featureNS: "http://www.opengeospatial.net/cite",
filter:Ffilter
})
}),
autoLoad: true
});

Then EditorGrid



    var cm = new Ext.grid.ColumnModel({
columns: [
{header: "id",
dataIndex:"id",
editor: new Ext.form.TextField({allowBlank: false})
}]
})


var ed_tab = new Ext.grid.EditorGridPanel({

store: st,
region: 'center',
cm: cm,
height: 200,
title:'Аттрибуты',
autoScroll: true,
bbar:[{
xtype: 'tbbutton',
cls: 'x-btn-icon',
tooltip: "Сделать что то",

id: "something",
icon: url_servlet+'externals/gxp/src/theme/img/silk/delete.png',
handler: function(){
ed_tab.store.proxy.protocol.commit(
myVecLayer.features
);
ed_tab.store.reload();
}
}]
})



var x = new Ext.Window({
title:'Аттрибуты',
items:[ed_tab]
})
x.show();

That all about attributes. To modifity geometry htere: Modify WFS with OpenLayers


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...