0

i use this example for doing my own wfs-T example. . And my code are same under link. My only problem is i don't change polygon default style. it gives error when i use openlayers style map. How can i change polygon style , i want to change color ,opacity,etc of polygon , please help?

http://dev.openlayers.org/examples/wfs-protocol-transactions.html

2 Answers 2

1

as user stuporglue already mentioned the style is not a specific wfs-t issue, but you can just have a look at a nice website with Information about the Feature-Style and Stylemaps: http://www.peterrobins.co.uk/it/olstyle.html

For your Vector-/WFS-T-Layer you could use something like that:

var defStyle = {
    fillColor: "#ff0000",
    strokeColor: "green",
    strokeOpacity: "0.7",
    strokeWidth: 3,
    cursor: "pointer"
};
var sty = OpenLayers.Util.applyDefaults(defStyle, OpenLayers.Feature.Vector.style["default"]);

var sm = new OpenLayers.StyleMap({
    'default': sty,
    'select': {
        strokeColor: "red",
        fillColor: "green"
    }
});

wfs = new OpenLayers.Layer.Vector("Editable Features", {
    styleMap: sm,
    strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
    projection: new OpenLayers.Projection("EPSG:4326"),
    protocol: new OpenLayers.Protocol.WFS({
        version: "1.1.0",
        srsName: "EPSG:4326",
        url: "http://demo.boundlessgeo.com/geoserver/wfs",
        featureNS: "http://opengeo.org",
        featureType: "restricted",
        geometryName: "the_geom",
        schema: "http://demo.boundlessgeo.com/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=og:restricted"
    })
});

Here's a working example of mine with a vector-layer-stylemap:

http://jsfiddle.net/expedio/yxr5wdjo/

2
  • your welcome. if the question is answered please don't forget to mark the question as answered.
    – Thomas B
    Mar 25, 2015 at 7:54
  • ok i give useful also your post thanx again
    – JavaMAN
    Mar 26, 2015 at 9:28
0

This isn't a WFS-T issue, just an OpenLayers issue. WFS-T is just the protocol for creating, editing and deleting features, it doesn't affect how the feature is displayed by OpenLayers.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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