将散列模式应用于openlayers中的多边形 [英] Apply hash pattern to polygon in openlayers

查看:100
本文介绍了将散列模式应用于openlayers中的多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Openlayers从KML文件中创建一个包含多边形的矢量层,我需要对这些多边形应用哈希"图案(对角线条纹).我知道Openlayers本身不支持在矢量层的多边形中添加背景图像,但我想知道是否有人对如何实现此目的有任何想法?矢量多边形的样式似乎仅限于纯色和不透明度.如果需要,我将扩展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.

推荐答案

使用SLD,现在可以完成此操作.不知道它是在2.11版中还是在主干开发中,但是我看到添加已提交关于6个月前.

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.

它使用ExternalGraphic,因此您可以设置所需图案或颜色的图像.

It uses an ExternalGraphic so you can set an image of whatever pattern or color you want.

这是 示例

Here's the Example

这篇关于将散列模式应用于openlayers中的多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆