For a project I am working on, I need to be able to put a polygon on a map using OpenLayers, based on a variable point that can be set by a user. The polygon is an isosceles triangle of which two legs should be exactly 1 kilometer and should originate from a point set by the user under an angle of 90 degrees. Does anyone know how this can be done?
[GIS] How to draw a polygon with preset length in OpenLayers
distanceopenlayers-2polygon-creation
Best Answer
The standard way to add a regular polygon to an OpenLayers map is with the createRegularPolygon method.
Here's an example:
In this example the lon/lat values are in degrees (e.g., EPSG:4326), and the radius (1.2) is in those map units as well.
EDIT: If you want a circle instead of a triangle, change the "sides" parameter (3 in the example above) to 20, which gives a good approximation of a circle.