Search code examples
geometryopenlayers-3

New geometry from area


I'm using OpenLayers 3 and I'm trying to create a geometry. I have a starting point (X,Y) and I need the geometry to be a rectangle of area = 10.000

How can I achieve the above?


Solution

  • If you want the rectangle to be a square buffer an extent around the starting point by half the side of your rectangle

    ol.geom.Polygon.fromExtent(ol.extent.buffer([x, y, x, y], Math.sqrt(area)/2))