Joh*_*ang 1 javascript openlayers-3
我想在多边形中添加图片,但是,我在openlayers 3中没有找到这样的功能。有什么办法可以实现这一点吗?
提前致谢!
从Pull Request #4632开始,您可以使用CanvasRenderingContext2D.fillStyle
asol.style.Fill#color
属性并创建一个模式。
像这样的东西:
var cnv = document.createElement('canvas');
var ctx = cnv.getContext('2d');
var img = new Image();
img.src = 'https://i.imgsafe.org/73d1273.png';
img.onload = function(){
var pattern = ctx.createPattern(img, 'repeat');
// featurePoly is ol.Feature(new ol.geom.Polygon(...))
featurePoly.setStyle(new ol.style.Style({
fill: new ol.style.Fill({
color: pattern
})
}));
};
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3475 次 |
最近记录: |