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开发者_JAVA技巧 for the replies
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.
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:
精彩评论