-1

I creat a new polygon but before saving i want to append some data such as polygon name , color etc. How can i do this ?

I am using this function

var SaveStrategy: new OpenLayers.Strategy.Save();

this.wfs = new OpenLayers.Layer.Vector("WFS-T" , {
        strategies: [new OpenLayers.Strategy.BBOX(), this.saveStrategy],
        projection:  new OpenLayers.Projection("EPSG:3857"),
        protocol:    new OpenLayers.Protocol.WFS({
            version:     "1.1.0",
            srsName:     "EPSG:3857",
            url:         "http://localhost:8080/geoserver/wfs",
            featureNS:   "http://localhost:8080/geoserver/mall",
            featureType:  stores,
            geometryName: 'geom'
        })

    });


var save = new OpenLayers.Control.Button({
            title: "Save Changes",
            trigger: function() {
                if(edit.feature) {
                    edit.selectControl.unselectAll();
                }
                Home.saveStrategy.save();
            },
            displayClass: "olControlSaveFeatures"
        });

Polygon Table:

gid | name    | background | geom
----+---------+------------+------------
1   | Store 1 | #FFFFF     | {geom_data}
  • What is the question exactly? – John Powell Dec 16 '15 at 12:39
2

Ok I found the problem

var draw = new OpenLayers.Control.DrawFeature(
        this.wfs, OpenLayers.Handler.Polygon,
        {
            title: "Draw Feature",
            displayClass: "olControlDrawFeaturePolygon",
            multi: false,
            featureAdded: function(object){

             /* Database Column Values Here :) */
                object.attributes = {
                    'background':'#00000',
                    'name':'test'
                }

                console.log(object);
            }
        }

    );

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.