I am creating a vector layer comprised of polygons from a KML file using Openlayers and I need to apply a "hash" pattern (diagonal striping) to the polygons. I know Openlayers doesn't natively support adding a background image to a polygon in a vector layer but I'm wondering if anyone has any ideas on how to accomplish this? The styling of a vector polygon appears to be limited to solid colors and opacity. If need be I'll extend OpenLayers to add this functionality in by manually drawing the hash lines within the polygon boundaries but I'm hoping someone has a simpler suggestion before I head down that road.
Using SLD this can now be done. Not sure if it's in version 2.11 or the trunk development but i saw the addition was committed about 6 months ago.
It uses an ExternalGraphic
so you can set an image of whatever pattern or color you want.
Here's the Example
I have not try this yet, but I have similar problem.
The solution I will try is svg pattern.
OpenLayers has SVG.js which is used to draw polygons. I will modify that to support patterns.
Look Image -->
http://i2.aijaa.com/b/00653/9707550.jpg
In this example i have modified http://openlayers.org/dev/examples/behavior-fixed-http-gml.html example to demonstrate pattern usage. --> Could this be good solution?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With