Reputation: 934
I just want to draw rectangle in for style.
if I do this
image: new ol.style.RegularShape({
fill: fill,
//stroke: stroke,
// offsetY: -25,
points: 4,
radius1: 30,
//radius2:20,
angle: Math.PI / 4
})
else if i do this
image: new ol.style.RegularShape({
fill: fill,
//stroke: stroke,
// offsetY: -25,
points: 4,
radius1: 30,
radius2:10,
angle: Math.PI / 4
})
How can I draw rectangle?
Upvotes: 0
Views: 1773
Reputation: 5647
You cannot draw a rectangle with ol.style.RegularShape
, because a rectangle is not a regular shape. Instead, you can use an ol.style.Icon
with a custom canvas:
var canvas = document.createElement('canvas');
canvas.width = 60;
canvas.height = 20;
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'red';
ctx.fillRect(0, 0, canvas.width, canvas.height);;
var imageStyle = new ol.style.Icon({
img: canvas,
imgSize: [60, 20]
});
Upvotes: 1