You may need to take this to the geoserver-users list, or the
openlayers-user list.
This email list is for those working on the geoserver project who are not
necessarily in position to help you debug an open layers application.
--
Jody Garnett
On 9 November 2016 at 19:52, rishe28 <[email protected]> wrote:
> I've tried replicating tutorial on how to edit WFS with
> OpenLayers(http://wordpress-dbauszus.rhcloud.com/wfs-t-
> with-openlayers-3-5/)
> but with my own WFS layer from Geoserver. Need some Javascript help finding
> what's wrong with it.
>
> I managed to load the WFS and my basemap successfully and managed to get
> the
> buttons to show up. The buttons appear correctly like in the working
> example
> , for some reason the geometry data isn't being saved. Delete button is
> working fine(whenever i delete a polygon it is deleted and also in the
> geoserver published layer) but editing, draw polygon, line,point are not
> working fine ie i am able to draw or edit the polygon or line, but is not
> saved and whenever i refresh the page it is showing the previous polygon
> not
> the edited one nor newly inserted one
>
> The bit of my code for posting is:
>
> var dirty = {};
> var formatWFS = new ol.format.WFS();
> var formatGML = new ol.format.GML({
> // featureNS: 'http://argeomatica.com',
> featureNS: 'http://www.opengis.net/cite',
> // featureType: 'playa_sample',
> featureType: 'NARAYANGARH',
> service: 'WFS',
> version: '1.1.0',
> request: 'GetFeature',
> srsName: 'EPSG:3857'
> });
> var transactWFS = function(p,f) {
> switch(p) {
> case 'insert':
> node = formatWFS.writeTransaction([f]
> ,null,null,formatGML);
> break;
> case 'update':
> node = formatWFS.writeTransaction(
> null,[f],null,formatGML);
> break;
> case 'delete':
> node = formatWFS.writeTransaction(
> null,null,[f],formatGML);
> break;
> }
> s = new XMLSerializer();
> str = s.serializeToString(node);
> // $.ajax('http://geoserver-dbauszus.rhcloud.com/wfs',{
> $.ajax('http://localhost:8080/geoserver/cite/wfs',{
> type: 'POST',
> dataType: 'xml',
> processData: false,
> contentType: 'text/xml',
> data: str
> }).done();
> }
>
> $('.btn-floating').hover(
> function() {
> $(this).addClass('darken-2');},
> function() {
> $(this).removeClass('darken-2');}
> );
>
> $('.btnMenu').on('click', function(event) {
> $('.btnMenu').removeClass('orange');
> $(this).addClass('orange');
> map.removeInteraction(interaction);
> select.getFeatures().clear();
> map.removeInteraction(select);
> switch($(this).attr('id')) {
>
> case 'btnSelect':
> interaction = new ol.interaction.Select({
> style: new ol.style.Style({
> stroke: new ol.style.Stroke({color: '#f50057',
> width: 2})
> })
> });
> map.addInteraction(interaction);
> interaction.getFeatures().on('add', function(e) {
> props = e.element.getProperties();
> if
> (props.status){$('#popup-status').html(props.status);}
> else{$('#popup-status').html('n/a');}
> if
> (props.tiendas){$('#popup-tiendas').html(props.tiendas);
> }else{$('#popup-tiendas').html('n/a');}
> coord = $('.ol-mouse-position').html().split(',');
> overlayPopup.setPosition(coord);
> });
> break;
>
> case 'btnEdit':
> map.addInteraction(select);
> interaction = new ol.interaction.Modify({
> features: select.getFeatures()
> });
> map.addInteraction(interaction);
>
> snap = new ol.interaction.Snap({
> source: layerVector.getSource()
> });
> map.addInteraction(snap);
>
> dirty = {};
> select.getFeatures().on('add', function(e) {
> e.element.on('change', function(e) {
> dirty[e.target.getId()] = true;
> });
> });
> select.getFeatures().on('remove', function(e) {
> f = e.element;
> if (dirty[f.getId()]){
> delete dirty[f.getId()];
> featureProperties = f.getProperties();
> delete featureProperties.boundedBy;
> var clone = new ol.Feature(featureProperties);
> clone.setId(f.getId());
> transactWFS('update',clone);
> }
> });
> break;
>
> case 'btnDrawPoint':
> interaction = new ol.interaction.Draw({
> type: 'Point',
> source: layerVector.getSource()
> });
> map.addInteraction(interaction);
> interaction.on('drawend', function(e) {
> transactWFS('insert',e.feature);
> });
> break;
>
> case 'btnDrawLine':
> interaction = new ol.interaction.Draw({
> type: 'LineString',
> source: layerVector.getSource()
> });
> map.addInteraction(interaction);
> interaction.on('drawend', function(e) {
> transactWFS('insert',e.feature);
> });
> break;
>
> case 'btnDrawPoly':
> interaction = new ol.interaction.Draw({
> type: 'Polygon',
> source: layerVector.getSource()
> });
> map.addInteraction(interaction);
> interaction.on('drawend', function(e) {
> transactWFS('insert',e.feature);
> });
> break;
>
> case 'btnDelete':
> interaction = new ol.interaction.Select();
> map.addInteraction(interaction);
> interaction.getFeatures().on('change:length', function(e)
> {
> transactWFS('delete',e.target.item(0));
> interaction.getFeatures().clear();
> selectPointerMove.getFeatures().clear();
> });
> break;
>
> default:
> break;
> }
> });
>
> My main problem is how to save user edited data
> to the WFS layer?
>
>
> In my code, while debugging s = new XMLSerializer(); str =
> s.serializeToString(node); str is jsfiddle.net/rishe/8nkayjon in the xml
> file it is showing the updated points also, but it is not updated in the
> shapefile only delete option is reflecting in the shapefile.please tell me
> where the problem is
>
>
>
> --
> View this message in context: http://osgeo-org.1560.x6.
> nabble.com/Editing-wfs-layer-tp5295098.html
> Sent from the GeoServer - Dev mailing list archive at Nabble.com.
>
> ------------------------------------------------------------
> ------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> _______________________________________________
> Geoserver-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geoserver-devel
>
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users