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.

2 Answers 2


Try this extension example -->


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

Here is the api -->http://viglino.github.io/ol-ext/doc/doc-pages/ol.interaction.DrawRegular.html


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.scale(radius2 / radius1, 1);
  polygon.rotate(rotation, center);
  if (!geometry) {
    geometry = polygon;
  } else {
  return geometry;

which has been modified slightly from this example:


by changing the fromCircle conditions

Moving geom.Polygon.circular in OpenLayers 3

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.