[OpenLayers-Dev] Chaging color and thickness of drawing lines and polygons

Eric Lemoine eric.c2c at gmail.com
Sat Aug 23 08:32:29 EDT 2008


If your code itself creates DrawFeature controls, you can pass a style
option to the underlying handler, e.g.

var s = OpenLayers.Util.applyDefaults({strokeWidth: 4},
var d = new OpenLayers.Control.DrawFeature(layer,
OpenLayers.Handler.Path, {handlerOptions: {style: s}});

I haven't tested this myself but it looks like it will work. Note that
the above code doesn't rely on public APIs, so it way break in the
future when upgrading to a new OL version.

If you use the editing toolbar, you won't be able to set the handlers'
style property as done above; I would then recommend to implement your
own editing toolbar control (or possibly improve OL's editing toolbar
and contribute your change to OL).

As for using right-click instead of double-click for ending drawing,
OpenLayers doesn't support it. You'll have to implement your own
drawing handlers possibly by inheriting from Handler.Path and
Handler.Polygon, or again bring new options to the existing handlers.

Hope this helps. Eric

2008/8/23, Darko Radiceski <radiceski at gmail.com>:
> Greetings all,
> Is it possible to change the color and thickness of lines that get drawn
> when drawing lines and polygons?
> Also is it possible to control the draw line ending event and also a polygon
> to be a right click instead of double click?
> Cheers
> Dan
> --
> Radiceski Dan
> University of Wollongong
> Australia
> SIFE - UOW Chapter - Alumni
> (School of Information Technology and Computer Science,University of
> Wollongong)
> Univeristy of Wollongong - Alumni

More information about the Dev mailing list