[OpenLayers-Users] Which OpenLayers.Feature.Vector.style is used while drawing?

Tim Schaub noreply at geocartic.com
Fri Mar 30 13:59:50 EDT 2007


Jeff Dege wrote:
> I'm trying to draw polygons in a different color than the default.  But
> I've only managed to change the color of the drawn polygons.
> 

Currently, the handler that does the drawing (Point, Path, or Polygon) 
is in charge if the style of your sketches (features before they are 
completed).

You can change the options for the handler by passing a handlerOptions 
object in your control constructor.  So, something like this would work:

     var options = {
         handlerOptions: {
             freehand: true,
             style: {
                 fillColor: "yellow",
                 fillOpacity: 0.4,
                 strokeColor: "green",
                 strokeOpacity: 1,
                 strokeWidth: 1,
                 pointRadius: 6
             }
         }
     };
     var control = new OpenLayers.Control.DrawFeature(polygonLayer,
                             OpenLayers.Handler.Polygon, options);

Now your polygon sketches will have a green outline and a yellow fill.

Note that this is subject to change before the release of 2.4.

Tim





More information about the Users mailing list