[OpenLayers-Users] drawing a box or circle

Michael mdm at yachtpc.com
Tue May 17 09:55:54 EDT 2011


Sure!

Depending on what you are doing, there are at least two ways built in.

One is you can style a marker (OpenLayers.Feature.Vector) with a 
"circle". Look for the "graphicName" attribute. This can be “circle” 
(default), “square”, “star”, “x”, “cross”, “triangle”. (See 
http://dev.openlayers.org/docs/files/OpenLayers/Feature/Vector-js.html)

And, you can use the regular polygon feature to just plain old draw a 
shape. With 20-40 sides, a polygon looks pretty circle-ish. Example 
here: http://openlayers.org/dev/examples/regular-polygons.html.
I create a grey circle ~100 nautical miles diameter with this code: new 
OpenLayers.Geometry.Polygon.createRegularPolygon(finish, 100.0/60, 20, 
0),{color:"#999999"});

If you need a non-standard shape, for the Feature.Vector, you can create 
a new graphicName. Here is how I create "boatright", a boat facing Right.
OpenLayers.Renderer.symbol.boatright = [45,0, 35,10, 0,10, 0,0, 25,0, 
25,-55, 0,-10, 25,-10, 25,-55, 45,-2, 25,-5, 25,0, 45,0];

Whee fun!



On 5/17/2011 6:17 AM, ulao wrote:
> I'm using the draw feature for making poly/polygons. I figure OL also has
> some built in support for rectangles and circles but dont see them?  If I
> need to make the drawing methods myself. Is there a way to use the current
> method and just limit the user.  For example a two point square drawing.
>
> --
> View this message in context: http://osgeo-org.1803224.n2.nabble.com/drawing-a-box-or-circle-tp6373056p6373056.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users


More information about the Users mailing list