Search code examples
javascriptopenlayers

Using OpenLayers and javascript to draw arcs or semi circles based on a point on a map


Note: I am not trying to draw an arc or semi circle that follows the curvature of the earth as has been asked in other questions. I want to be able to create arcs and semi circles based on a point on a map and a given radius.

I want it to look very similar to this:

Arcs based on a point

I know how to make circles on a map so I am imagining some way to use circles around a point and then possibly styling the circles to only show part of the edge making an arc or semi circle.


Solution

  • The comment from @Mike is what I was looking for. He said:

    "Create a polygon from a circle and take as many coordinates from it as you need for your arc, e.g. for 90 degrees new LineString(fromCircle(new Circle(center, radius), 64, startAngle).getCoordinates()[0].slice(0, 17))"

    I setGeometry(...) on my feature with the above line and it worked.