javascript - In openlayers 3, how to fill the polygon with a picture from a url? -


i add picture in polygon, however, not find such function in openlayers 3. there way achieve this?

thanks in advance!

since pull request #4632 can use canvasrenderingcontext2d.fillstyle ol.style.fill#color property , create pattern.

something this:

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 ol.feature(new ol.geom.polygon(...))   featurepoly.setstyle(new ol.style.style({     fill: new ol.style.fill({       color: pattern     })   })); }; 

live demo.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -