创建OpenLayer圈时出现问题

时间:2011-07-03 16:58:10

标签: javascript geometry openlayers

如何在openlayer地图中绘制圆圈?我尝试过差异方式,但它不起作用..请帮我代码。我使用了以下代码..但它创建了多边形

var p1 = new OpenLayers.Geometry.Point(439000, 114000);
var p2 = new OpenLayers.Geometry.Point(440000, 115000);
var p3 = new OpenLayers.Geometry.Point(437000, 116000);
var p4 = new OpenLayers.Geometry.Point(436000, 115000);
var p5 = new OpenLayers.Geometry.Point(436500, 113000);
var points = [];
points.push(p1);
points.push(p2);
points.push(p3);
points.push(p4);
points.push(p5);

var linearRing = new OpenLayers.Geometry.LinearRing(points);
var polygonFeature = new OpenLayers.Feature.Vector(linearRing, null, style_green);
vectorLayer.addFeatures([polygonFeature])

1 个答案:

答案 0 :(得分:10)

我使用OpenLayers.Geometry.Polygon.createRegularPolygon执行此操作:

var circle = OpenLayers.Geometry.Polygon.createRegularPolygon(
    new OpenLayers.Geometry.Point(0, 0),
    1,
    30
);
var feature = new OpenLayers.Feature.Vector(circle);

还有你的圈子。