Sunday 26 July 2015

openlayers 2 - What is wrong with my WFS-T protocol setup?


So I want to transfer some Vector Layer Features from javascript code to my geoserver and then to postGIS, my code looks like this:


    saveStrategy = new OpenLayers.Strategy.Save();


saveStrategy.events.register("success", '', alert('Success'));
saveStrategy.events.register("failure", '', alert('Failure'));

stationsMarkersLayer1a = new OpenLayers.Layer.Vector("ODC_Private_Graphics_Data", {
strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
projection: 'EPSG:4326',
protocol: new OpenLayers.Protocol.WFS({
version: '1.1.0',
url: "file://http://localhost:8080/geoserver/wfs",

featurePrefix: 'leoforia',
featureNS: 'http://leoforia/application/catalogLayer',
featureType: 'no 1 points',
geometryName: 'geom',
extractAttributes: true,
srsName: 'EPSG:4326',
isBaseLayer: false,
visibility: true ,
schema: 'http://localhost:8080/geoserver/wfs/DescribeFeatureType?version=1.1.0&;typename=leoforia:ODC_Private_Graphics_Data'})
});


stationsMarkersLayer1a.id = '1' ;
stationsMarkersLayer1a.name = 'Blah Blah';

var stationMarkers_1a = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(22.96336,39.35071).transform(fromProjection, toProjection),
{description:'Mark1'} ,
{externalGraphic: 'redMarker.png', graphicHeight: 25, graphicWidth: 21, graphicXOffset:-12, graphicYOffset:-25 }
);


stationsMarkersLayer1a.addFeatures(stationMarkers_1a);

map.addLayer(stationsMarkersLayer1a);

saveStrategy.save() //I have seen this command with a semi colon and without and I have tried both.

Supposing 'leoforia' is the name of the workspace,Workspace URI is right and I have a layer in PostGIS and GeoServer named 'no 1 points' and the column name is indeed 'geom', what is wrong with my code? Why won't it save the Geometry Points/Feature to the database? Also have in mind that all this code is inside my init() funciton that runs on page load.


For any additional information, please ask!




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...