admin管理员组文章数量:1394585
I am creating a vector layer prised 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 acplish 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.
I am creating a vector layer prised 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 acplish 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.
Share Improve this question asked Feb 22, 2012 at 15:43 TheOxTheOx 2,22825 silver badges30 bronze badges 3- Do you mean styling polygon borders (exterior) or internal polygon ? – Myra Commented Feb 23, 2012 at 13:56
- @Myra - internal polygon – TheOx Commented Feb 23, 2012 at 16:37
- I was going to say,polygon has only outer boundary stroke style as hash,but currently no support for internal style except for color & opacity – Myra Commented Feb 24, 2012 at 6:03
2 Answers
Reset to default 5Using 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 mitted 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./b/00653/9707550.jpg
In this example i have modified http://openlayers/dev/examples/behavior-fixed-http-gml.html example to demonstrate pattern usage. --> Could this be good solution?
本文标签: javascriptApply hash pattern to polygon in openlayersStack Overflow
版权声明:本文标题:javascript - Apply hash pattern to polygon in openlayers - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744096486a2590377.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论