用图案填充多边形不适用于传单

编程入门 行业动态 更新时间:2024-10-27 21:25:36
本文介绍了用图案填充多边形不适用于传单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我尝试渲染填充有图案的SVG多边形.充满模式的SVG.path不起作用.如您在 jsfiddle 中所看到的,填充的背景在Firefox中显示为透明,在Chrome中显示为黑色.

I try to render a SVG polygon filled with pattern. SVG.path filled with pattern doesn't work. As you can see in this jsfiddle, filled background shows up transparent in Firefox and black in Chrome.

该示例基于 leaflet GeoJSON示例,并使用了 carto .

The example is based on leaflet GeoJSON Example and uses the diagonalHatch pattern described by carto.

<defs> <pattern id="diagonalHatch" patternUnits="userSpaceOnUse" x="0" y="0" width="105" height="105"> <g style="fill:none; stroke:black; stroke-width:1"> <path d="M0 90 l15,15"/><path d="M0 75 l30,30"/> <path d="M0 60 l45,45"/><path d="M0 45 l60,60"/> <path d="M0 30 l75,75"/><path d="M0 15 l90,90"/> <path d="M0 0 l105,105"/><path d="M15 0 l90,90"/> <path d="M30 0 l75,75"/><path d="M45 0 l60,60"/> <path d="M60 0 l45,45"/><path d="M75 0 l30,30"/> <path d="M90 0 l15,15"/> </g> </pattern> </defs>

如 jsfiddle 所示,将SVG多边形复制到地图下方,使其可以在Chrome上运行,但是不在Firefox上.应用将这种样式添加到SVG.path的填充模式:

As this jsfiddle shows, copying the SVG polygons below the map, makes it work on Chrome but not on Firefox. Apply a fill pattern adding this style to SVG.path:

style="fill: url(#diagonalHatch)"

我真的不确定这是传单中的错误还是与Firefox和Chrome上的SVG实施冲突.

I'm really not sure if this is a bug in leaflet or some conflict with SVG implementation on Firefox and Chrome.

推荐答案

我为此编写了一个传单插件,您可以尝试一下, github/lnaweisu/leaflet-polygon-fillPattern

I've wrote a leaflet plugin for this, you may try it, github/lnaweisu/leaflet-polygon-fillPattern

更多推荐

用图案填充多边形不适用于传单

本文发布于:2023-08-02 03:49:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1274372.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多边形   传单   图案   不适用于

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!