[GIS] Draw Rectangle using OpenLayers 4

openlayers

I just want to draw rectangle 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
    })

it gives me this square
enter image description here

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
    })

it gives me this
enter image description here

How can I draw a rectangle?

Best Answer

The OpenLayers website has lots of examples that you may find helpful. This link goes into details on how to draw shapes. http://openlayers.org/en/latest/examples/draw-shapes.html?q=draw

Checkout more on the examples page.