# Drawing ellipse in OpenLayers

How to draw ellipse in OpenLayers? I have not problems with drawing circles, or MultiPolygons, but i need to draw simple ellipse and not found any functions for this action.

Try this extension example -->

http://viglino.github.io/ol-ext/examples/interaction/map.interaction.drawregular.html

Use a number less than three and you will be able to draw an ellipses.

I should use the code like this:

`````` var ellipseInteraction = new ol.interaction.Draw({
type: 'LineString',
source: vectorLayer.getSource(),
maxPoints: 3,
geometryFunction: function(coordinates, geometry) {
var center = coordinates[0];
var first = coordinates[1];
var dx = center[0] - first[0];
var dy = center[1] - first[1];
var radius1 = Math.sqrt(dx * dx + dy * dy);
if (coordinates.length > 2) {
var last = coordinates[2];
dx = center[0] - last[0];
dy = center[1] - last[1];
}
var radius2 = Math.sqrt(dx * dx + dy * dy);
var rotation = Math.atan2(dy, dx);
var circle = new ol.geom.Circle(center, radius1);
var polygon = new ol.geom.Polygon.fromCircle(circle, 64);
polygon.rotate(rotation, center);
if (!geometry) {
geometry = polygon;
} else {
geometry.setCoordinates(polygon.getCoordinates());
}
return geometry;
}
});
``````

which has been modified slightly from this example:

https://codesandbox.io/s/draw-shapes-fr7dz?file=/index.js:111-163

by changing the `fromCircle` conditions

Moving geom.Polygon.circular in OpenLayers 3