Get Radius in epsg 4326 with Openlayers 3

What is the best method for getting the radius of a circle in Openlayers 3 in epsg 4326 (geodesic)? I'm using this example for a base and trying to draw a circle while getting the radius, but using proj 4326 is proving difficult. Here's my code:

``````var pointerMoveHandler = function(evt) {
if (evt.dragging) {
return;
}
var tooltipCoord = evt.coordinate;

if (sketch) {
var output;
var geom = (sketch.getGeometry());
if (geom instanceof ol.geom.Cirlce) {
output = formatCircle(/** @type {ol.geom.Circle} */ (geom));

measureTooltipElement.innerHTML = output;
measureTooltip.setPosition(tooltipCoord);
}
};

var sourceProj = map.getView().getProjection();
var geom = /** @type {ol.geom.Circle} */(Circle.clone().transform(
sourceProj, 'EPSG:4326'));
var output;
if (area > 10000) {
output = (Math.round(area / 1000000 * 100) / 100) +
' ' + 'km<sup>2</sup>';
} else {
output = (Math.round(area * 100) / 100) +
' ' + 'm<sup>2</sup>';
}
return output;
};
``````

radius = Math.abs(wgs84Sphere.geodesicArea(center)); isn't right, but I'm not sure what to put there....

• I need to know where do you get the function formatRadius(). Did you written by your own? Or did you found it somewhere on OL3 examples? Thank you Mar 15, 2017 at 10:41
• I received some help. It wasn't on the examples.
– Dean
Mar 16, 2017 at 12:40

Found it..

``````var formatRadius = function(Circle) {
if (geodesicCheckbox.checked) {
var center = Circle.getCenter();
var pointOnPerimeter = [center[0], center[1] + Circle.getRadius()]
var sourceProj = map.getView().getProjection();
var c1 = ol.proj.transform(center, sourceProj, 'EPSG:4326');
var c2 = ol.proj.transform(pointOnPerimeter, sourceProj,                    'EPSG:4326');