我想在openlayers功能中旋转线条图案填充。在外部打开层测试时,旋转效果很好,但是当尝试将其用作特征填充颜色时,旋转不起作用。
p = ctx.createPattern(canvasPattern, 'repeat');
//the following code has no effect on p in openlayers, while it works independent on canvas
ctx.fillStyle = p;
ctx.translate(cw / 2, ch / 2);
ctx.rotate(0.5 * Math.PI / 4); // the most important!
ctx.fillRect(-cw, -ch, cw * 2, ch * 2);
ctx.setTransform(1, 0, 0, 1, 0, 0);
featurePoly.setStyle(new ol.style.Style({
fill: new ol.style.Fill({
color: p
})
}));