Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply hash pattern to polygon in openlayers

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.

like image 282
TheOx Avatar asked Feb 22 '12 15:02

TheOx


2 Answers

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

enter image description here

like image 130
capdragon Avatar answered Oct 31 '22 20:10

capdragon


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?

like image 20
Rami Avatar answered Oct 31 '22 20:10

Rami