webs86
webs86

Reputation: 319

can I customize the background of a polygon in OpenLayers?

Can I customize the background (with an image, for example) with OpenLayers on a polygon?

Thanks for the replies

Upvotes: 2

Views: 1480

Answers (2)

Neffets
Neffets

Reputation: 158

Okay, question and answer are old, but no matter. You can now use in OL 2.13.1 this snippset:

var _styleMap = new OpenLayers.StyleMap();
var _ruleDef = [new OpenLayers.Rule({
    symbolizer: {
        externalGraphic: "vertical1.png", //use your bitmap
        graphic: true,
        graphicFormat: "image/png",
    },
    elseFilter: true
})];
_styleMap.styles["default"].addRules(_ruleDef);
yourLayer.styleMap = _styleMap; // put the new StyleMap on your Layer
yourLayer.redraw();

The Result should look like: enter image description here

Upvotes: 0

younes0
younes0

Reputation: 2302

All WFS / Vector style properties are on http://docs.openlayers.org/library/feature_styling.html
According to that link, you can't set a background image for polygons. Try to do it on the server-side, it's possible with MapServer if you use it.

Upvotes: 2

Related Questions