openlayers矢量圆形获取圆心和半径

来源:互联网 发布:linux 进程网络流量 编辑:程序博客网 时间:2024/05/22 08:28

在地图初始化前定义的交互:

var interaction = new ol.interaction.Draw({            source: this.source,            type:('Circle'), });


需要使用变量保存起来,这里使用 interaction 保存。

获取圆心和半径需要结合交互:如下

interaction.on("drawend", function (event) {            var centerLogLat,radius;            var circle = event.feature.getGeometry();            centerLogLat = circle.getCenter()            radius = circle.getRadius();            console.log("圆心坐标:"+centerLogLat+";半径:"+radius+"m")})


输出的结果正是圆心坐标和半径!