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  }



    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!

  • 1
    I would do a simpler test before: try adding a wfs service to a vector layer (like you're doing via the protocol) and see if the features on your wfs are displaying – plablo09 Oct 15 '14 at 16:11
  • all the features are displayed on map but they are not saved at the 'no 1 points' aka featureType on Geoserver and postgis – drizo Oct 15 '14 at 20:52
  • @plablo09 the problem is at writing stuff on the server and database – drizo Oct 15 '14 at 22:31
  • I would drop these to lines: stationsMarkersLayer1a.id = '1' ; stationsMarkersLayer1a.name = 'Blah Blah'; And define those attribute inside the feature definition (the same way you're adding description and external graphic – plablo09 Oct 16 '14 at 18:29
  • @plablo09 these two work just fine, I can't find what is wrong I am desperate! – drizo Oct 17 '14 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.