Openlayers 3 如何在Openlayers 3中获取用户绘制的圆的坐标?

Openlayers 3 如何在Openlayers 3中获取用户绘制的圆的坐标?,openlayers-3,Openlayers 3,我在Openlayers3中有一个静态图像层,用户可以在其中绘制圆形、点和多边形等特征 我可以用以下代码获得点、多边形和线串的坐标: draw_interaction.on('drawend', function(event) { var geoJsonGeom = new ol.format.GeoJSON(); var pp = geoJsonGeom.writeGeometry(event.feature.getGeometry()); console.lo

我在Openlayers3中有一个静态图像层,用户可以在其中绘制圆形、点和多边形等特征

我可以用以下代码获得点、多边形和线串的坐标:

draw_interaction.on('drawend', function(event) {
    var geoJsonGeom = new ol.format.GeoJSON();    
    var pp = geoJsonGeom.writeGeometry(event.feature.getGeometry());
    console.log(pp);
});
这将按预期输出坐标:

"{"type":"Point","coordinates":[1441.9187662124637,1365.3125032424925]}"
然而,我不知道如何得到一个圆的坐标。圆形情况下的输出如下所示:

"{"type":"GeometryCollection","geometries":[]}"
Openlayers的版本是v3.5.0

编辑: 为了获得中心和半径,您必须使用特征本身,而不是其GeoJSON输出(因为GeoJSON没有圆):


GeoJSON没有圆形几何图形。正确的解决方案是在序列化之前用多边形近似圆。使用新的几何体选项ol.interaction.Draw可能可以实现这一点。请参见: 有关此主题的更深入讨论,请参见本github问题:


适用于所有正在搜索解决方案以从圆中获取坐标的开发人员:

“Polygon”类得到了一个名为“fromcycle”的方法。从那里你可以使用
.getCoordinates()

它也可以在INTV3.6.0中使用

啊,我明白了。我不明白问题出在GeoJSON上。非常感谢。
var circle = event.feature.getGeometry();
console.log('radius:' + circle.getRadius());
console.log('center:' + circle.getCenter());
draw_interaction.on('drawend', function(event) {
    var geoJsonGeom = new ol.format.GeoJSON();    
    var pp = geoJsonGeom.writeGeometry(event.feature.getGeometry());
    console.log(pp);
});