Can I draw a circle on open layer

Hi All,

Can I draw a circle on open layer? If so,how can i make it? Any examples are appreciated :slight_smile:

thx,
Baron

Use OpenLayers.Geometry.Polygon.createRegularPolygon function with sides parameter >= 20.

http://dev.openlayers.org/apidocs/files/OpenLayers/Geometry/Polygon-js.html#OpenLayers.Geometry.Polygon.createRegularPolygon

Or using a Point with a radius and style.

See OL examples: http://openlayers.org/dev/examples/draw-feature.html

Hi Pawel,thx for the help,now i use below code to draw circle,not sure i can set any attribute to make it draw ellipse?


new OpenLayers.StyleMap({
	        "default": new OpenLayers.Style({
	            pointRadius: "${type}", // sized according to type attribute,from getCircleFeature
	            //fillColor: "#ffcc66",
	            //graphicXOffset: 10,
	            strokeColor: "#ff9933",
	            strokeWidth: 2,
	            graphicZIndex: 1,
	            fillOpacity:0
	            //graphicName:circle,start,cross,triangle
	        }),
	        "select": new OpenLayers.Style({
	            fillColor: "#66ccff",
	            strokeColor: "#3399ff",
	            graphicZIndex: 2
	        })
	    })

Hi Lambertus thx for the help,can I set some attributes in below code to dreaw ellipse?


new OpenLayers.StyleMap({
	        "default": new OpenLayers.Style({
	            pointRadius: "${type}", // sized according to type attribute,from getCircleFeature
	            //fillColor: "#ffcc66",
	            //graphicXOffset: 10,
	            strokeColor: "#ff9933",
	            strokeWidth: 2,
	            graphicZIndex: 1,
	            fillOpacity:0
	            //graphicName:circle,start,cross,triangle
	        }),
	        "select": new OpenLayers.Style({
	            fillColor: "#66ccff",
	            strokeColor: "#3399ff",
	            graphicZIndex: 2
	        })
	    })