[OpenLayers-Users] Need help changing fill/stroke colour for a RegularPolygon

noosy vanessa.towers at dsto.defence.gov.au
Fri Oct 9 00:01:42 EDT 2009


Hi,

I have the following code:

var sketchSymbolizers = {
    "RegularPolygon": {
        strokeWidth: 2,
        strokeOpacity: 1,
        strokeColor: "#666666",
        fillColor: "#cbc7f0",
        fillOpacity: 0.3
    },
    "Point": {
        pointRadius: 4,
        graphicName: "square",
        fillColor: "white",
        fillOpacity: 1,
        strokeWidth: 1,
        strokeOpacity: 1,
        strokeColor: "#666666"
    },
    "Polygon": {
        strokeWidth: 2,
        strokeOpacity: 1,
        strokeColor: "#666666",
        fillColor: "#cbc7f0",
        fillOpacity: 0.3
    }
};

var style = new OpenLayers.Style();
style.addRules([
    new OpenLayers.Rule({symbolizer: sketchSymbolizers})
]);

var sm = new OpenLayers.StyleMap({"default": style});

var polyOptions = {sides: 40, persist: true, layerOptions: {styleMap: sm}};

 var measureCirc = new GeoExt.Action({
        icon: './draw_circle_off.png',
        cls: 'x-btn-icon',
        control: new OpenLayers.Control.Measure(
            OpenLayers.Handler.RegularPolygon, {
               handlerOptions: polyOptions
           }
        ),
        map: mapPanel.map,
        // button options
        toggleGroup: "draw",
        allowDepress: true,
        // check item options
        group: "draw"
    });

For some reason my circle is still orange :(

The above code works fine with a OpenLayers.Handler.Polygon so what is the
problem with the RegularPolygon?

I have gone into Firebug and modified the following

measureCirc -> control -> handler -> style -> fillColor -> "cbc7f0"

... and the colour changes to purple :) But I don't know how to do this
programmatically as everything I have tried has had no effect. Please direct
me as to how I can change the colour (so that it remains this colour on
zoom/pan also) so long as the geometry persists.

-- 
View this message in context: http://n2.nabble.com/Need-help-changing-fill-stroke-colour-for-a-RegularPolygon-tp3792284p3792284.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list