title: OpenLayers - Circle coordinates are missing
body: <p>I would like to have an option to export my drawings as geoJSON files. So far I've managed perfectly with all of them except for the circle, which comes admittedly with no geometries at all!</p>
  <p><a href="https://i.stack.imgur.com/FFX94.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FFX94.jpg" alt="enter image description here" /></a></p>
  <p>I know, that GeoJSON format can render a pure circle, and we need to model it as the points as per this thread:</p>
  <p><a href="https://stackoverflow.com/questions/17691956/how-to-define-a-circle-using-geojson">How to define a circle using GeoJson?</a>
  <a href="https://docs.mongodb.com/manual/tutorial/query-a-2dsphere-index/" rel="nofollow noreferrer">https://docs.mongodb.com/manual/tutorial/query-a-2dsphere-index/</a></p>
  <p>I am fully aware of it, that's why I started to modify my code in order to make the circle physically visible.</p>
  <p>My problem is very similar to this one:</p>
  <p><a href="https://stackoverflow.com/questions/41245206/cant-save-features-of-drawn-circle-to-json-in-openlayers-3">Can&#39;t save features of drawn Circle to JSON in Openlayers 3</a></p>
  <p>and similar to the solution below:</p>
  <p><a href="http://geoadmin.github.io/ol3/apidoc/sphere.js.html" rel="nofollow noreferrer">http://geoadmin.github.io/ol3/apidoc/sphere.js.html</a></p>
  <p>After amending the code:</p>
  <pre><code>   var wgs84Sphere = new ol.sphere(6378137);
  
     var circleInteraction = new ol.interaction.Draw({
  geometryFunction: function(coordinates, geometry) {
    if (!geometry) {
      geometry = new ol.geom.Polygon(null);
    }
    var center = coordinates[0];
    var last = coordinates[1];
    var dx = center[0] - last[0];
    var dy = center[1] - last[1];
    var radius = Math.sqrt(dx * dx + dy * dy);
    var circle = ol.geom.Polygon.circular(wgs84Sphere, ol.proj.toLonLat(center), radius);
    circle.transform('EPSG:4326', 'EPSG:3857');
    geometry.setCoordinates(circle.getCoordinates());
    return geometry;
    },
    type: 'Circle',
    source: vectorLayer.getSource()
    });
    circleInteraction.setActive(false);
    circleInteraction.on('drawend', onDrawend );
  </code></pre>
  <p>I have received an error:</p>
  <p><strong>Uncaught TypeError: ol.sphere is not a constructor</strong></p>
  <p>which is caused by the OpenLayers library upgrade and is not been valid anymore since version 5.0.0.
  <a href="https://github.com/openlayers/openlayers/issues/9046" rel="nofollow noreferrer">https://github.com/openlayers/openlayers/issues/9046</a></p>
  <p>regarding this situation, I've tried to change the <code>wgs84Sphere</code> variable</p>
  <pre><code>  var polygon_geometry = new ol.geom.Polygon;
  
    var wgs84Sphere = ol.sphere.getArea(polygon_geometry, projection='EPSG:4326', radius=6378137)
  </code></pre>
  <p>but it didn't work either</p>
  <p><strong>Uncaught TypeError: Cannot read properties of undefined (reading    SimpleGeometry.js:170</strong></p>
  <p>pointing the line</p>
  <pre><code>    if (coordinates.length === 0) {
  </code></pre>
  <p>Is it possible to generate the .geoJSON geometries for circle then?</p>
  <p>My full JSFiddle is here:</p>
  <p><a href="https://jsfiddle.net/pet6h30d/" rel="nofollow noreferrer">https://jsfiddle.net/pet6h30d/</a></p>