4

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?

4
  • Is a rectangle is a regular shape? I think you can not use ol.style.RegularShape to generate a rectangle.
    – jgrocha
    Mar 21, 2017 at 21:45
  • @jgrocha ol.style includes this classes AtlasManager- Circle- Fill- Icon- Image- RegularShape- Stroke- Style- Text
    – BK52
    Mar 22, 2017 at 12:07
  • @jgrocha i think only RegularShape class relevant with Rectangle
    – BK52
    Mar 22, 2017 at 12:10
  • On your style, you have to create a polygon (a new geometry) from the feature's geometry, like in the following example: openlayers.org/en/latest/examples/polygon-styles.html In the example, the second style is based on a new geometry (MultiPoint) based on the feature's geometry. Try that, and if you can't do it, post here your attempt and we will help you based on your code.
    – jgrocha
    Mar 22, 2017 at 15:14

1 Answer 1

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.